1.解压源码包
# 使用通用二进制包"mysql-5.5.51-linux2.6-x86_64.tar.gz", 解压后初始化即可
shell> wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.55-linux2.6-x86_64.tar.gz
shell> tar zxvf mysql-5.5.55-linux2.6-x86_64.tar.gz -C /usr/local/
shell> cd /usr/local
shell> ln -sv mysql-5.5.55-linux2.6-x86_64 mysql
2.创建用户和组
shell> groupadd -r -g 306 mysql
sehll> useradd -g 306 -r -u 306 mysql
shell> id mysql
uid=306(mysql) gid=306(mysql) groups=306(mysql)
3.更改MySQL目录下的文件的所属主和所属组
shell> chown -R mysql:mysql /usr/local/mysql/*
4.创建数据目录, 并且设置相关权限
# 创建"/mydata/data"作为存放数据目录
shell> mkdir -p /mydata/data
shell> chown -R mysql:mysql /mydata/data
shell> chmod 750 /mydata/data/
5.初始化MySQL
shell> cd /usr/local/mysql
shell> /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/mydata/data
6.创建并配置MySQL配置文件
# 默认配置文件路径: /usr/local/mysql/support-files
shell> cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf
# 在[mysqld]下面添加"datadir = /mydata/data"
shell> vim /etc/my.cnf
[mysqld]
......
datadir = /mydata/data
7.启动MySQL并且添加自动启动
shell> cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
shell> chmod 755 /etc/init.d/mysqld
shell> chkconfig --add mysqld
shell> service mysqld start
网友评论