Home > Database > Mysql Tutorial > Linux下Mysql源码安装笔记

Linux下Mysql源码安装笔记

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:50:57
Original
1038 people have browsed it

很长没有写点东西了,在工作的这些日子,得到了一些安装Mysql的方法,此方法可以同时在一台Linux服务上安装多个Mysql.准备Mysql的源码,版本号为

很长没有写点东西了,在工作的这些日子,得到了一些安装Mysql的方法,此方法可以同时在一台Linux服务上安装多个Mysql.

准备Mysql的源码,版本号为Mysql-5.0.20a.tar.gz,当然其它的也行,只做为测试.Linux用Red Hat Linux as 4.

安装步骤:

1.解压Mysql-5.0.20a.tar.gz.

命令: tar -zxvf Mysql-5.0.20a.tar.gz

2.配置 Mysql

命令:./configure --prefix=/test/Mysql --with-charset=gbk

说明:安装到/text/Mysql下,语言用gbk.当然用别的也行,还有其它参数可以查看相关文档.

3.编译,安装

命令:

make

make install

这两个命令发的时间较长.

4.创建用户和组.

groupadd Mysql

useradd -g Mysql Mysql

5.进入Mysql目录.创建var目录.并把./share/Mysql/my-medium.cnf 拷到Mysql目录下并改名为my.cnf.

>mkdir var

>mv share/Mysql/my-medium.cnf my.cnf

6.配置my.cnf

配置主要把安装的目录的那几项打开就行.

改动如下:

[client]
#password = your_password
port = 3306
socket = /tmp/Mysql3306.sock

# The Mysql server
[Mysqld]
port = 3306
socket = /tmp/Mysql3306.sock

打开下面几项

innodb_data_home_dir = /test/Mysql/var/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /test/Mysql/var/
innodb_log_arch_dir = /test/Mysql/var/

7.安装数据库

命令:./bin/Mysql_install_db --defaults-file=/test/Mysql/my.cnf --user=Mysql

说明:必须用参数--defaults-file指定my.cnf,否则系统用默认的/etc/my.cnf.

8.安装完后,可以看到Mysql/var目录下有数据文件,然后用下面命令设置权限:

shell> chown -R root .
shell> chown -R Mysql var
shell> chgrp -R Mysql .

9.启动数据库.

./bin/Mysqld_safe --defaults-file=/test/Mysql/my
.cnf --user=Mysql &

10.进入数据库.

./bin/Mysql -u root --socket=/tmp/Mysql3306 --defaults-file=/test/Mysql/my.cnf

默认时没有密码,当然如果你删除/etc/my.cnf,可以不要后面的--defaults-file=/test/Mysql/my.cnf
./bin/Mysql -u root --socket=/tmp/Mysql3306 也就行了,原因大家应该知道吧!^_^!

11.设为服务并自启动.

对于设置为服务只要把Mysql/share/Mysql/Mysql.server放到/etc/init.d/下改名为Mysql

命令:

mv share/Mysql/Mysql.server /etc/init.d/Mysql

chmod 775 /etc/init.d/Mysql

chkconfig --add Mysql

总结,这只是安装了一个3306端口的Mysql,如果要在装一个msyql,步骤一样,只要改动my.cnf文件的内容.

[client]
#password = your_password
port = 3310
socket = /tmp/Mysql3310.sock

# The Mysql server
[Mysqld]
port = 3310
socket = /tmp/Mysql3310.sock

假如有问题的话,可以发邮件.

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template