CentOS6.10中安装MySQL5.6
软件准备:CentOS-6.10-x86_64-minimal.iso、mysql-5.6.25.tar.gz(源码安装包)
1、mkdir -p /var/lib/mysql
2、yum install cmake make gcc-c++ bison-devel ncurses-devel git -y
3、useradd mysql -s /sbin/nologin -M
4、chown -R mysql.mysql /var/lib/mysql
5、tar xf mysql-5.6.25.tar.gz
6、cd mysql-5.6.25
7、cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/var/lib/mysql -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
参数解释:
DCMAKE_INSTALL_PREFIX:安装目录
DMYSQL_DATADIR:数据库 数据目录
DMYSQL_UNIX_ADDR:sock存放目录
DMYSQL_USER: 用户
DEXTRA_CHARSETS:额外的字符集
DDEFAULT_CHARSET:默认字符集
DDEFAULT_COLLATION:默认编码
DENABLED_LOCAL_INFILE:可以使用load data infile命令从本地导入文件
DWITH_INNOBASE_STORAGE_ENGINE:支持InnoDB存储引擎,
DWITH_FEDERATED_STORAGE_ENGINE:支持federated存储引擎
DWITH_BLACKHOLE_STORAGE_ENGINE:支持blackhole存储引擎
DWITHOUT_EXAMPLE_STORAGE_ENGINE:不支持example存储引擎
8、make && make install
9、echo “export PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib” >> /etc/profile
10、source /etc/profile
11、/bin/cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
12、cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
13、chmod 700 /etc/init.d/mysqld
14、chown -R mysql:mysql /usr/local/mysql
15、chmod -R 755 /usr/local/mysql
16、chkconfig --add mysqld
17、chkconfig mysqld on
18、/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/var/lib/mysql --user=mysql
19、/etc/init.d/mysqld start
20、/usr/local/mysql/bin/mysql -e “update mysql.user set password=password(‘root’) where host=‘localhost’ and user=‘root’;”
/usr/local/mysql/bin/mysql -e “update mysql.user set password=password(‘root’) where host=‘127.0.0.1’ and user=‘root’;”
/usr/local/mysql/bin/mysql -e “delete from mysql.user where password=’’;”
/usr/local/mysql/bin/mysql -e “flush privileges;”