1.上传安装安装包mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz到/home/mysqlintall目录并解压
2.建立用户mysql和组
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
3.创建连接到/usr/local/mysql
ln -s /home/mysqlinstall/mysql-5.7.14-linux-glibc2.5-x86_64 mysql
4.修改用户属组和属主
[root@mysqlslave mysql]# chown -R mysql .
[root@mysqlslave mysql]# chgrp -R mysql .
5.整理mysql配置文件my.cnf
[root@mysqlmaster support-files]# cat /etc/my.cnf
# Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208slow-query-log-file = /mysqldata/mysql-slow.log
6.初始化mysql
mysqld --initialize --user=mysql
7.启动验证mysql
[root@mysqlmaster bin]# mysqld_safe --user=mysql
2017-06-20T03:32:06.621381Z mysqld_safe Logging to '/mysqldata/mysql-error.log'.
2017-06-20T03:32:06.645907Z mysqld_safe Starting mysqld daemon with databases from /mysqldata/data
7.配置mysql作为服务启动
[root@mysqlmaster support-files]# cp mysql.server /etc/init.d/mysqld
[root@mysqlmaster support-files]# chmod 755 /etc/init.d/mysqld
[root@mysqlmaster support-files]# chkconfig --add mysqld
[root@mysqlmaster support-files]# service mysqld status
MySQL running (29666) [纭甝
[root@mysqlmaster support-files]# service mysqld stop
Shutting down MySQL.. [纭甝
8.遇到问题
2017-06-20T03:25:05.274986Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
2017-06-20T03:25:05.275227Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2017-06-20T03:25:05.389533Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2017-06-20T03:25:05.389604Z 0 [ERROR] Aborting
解决配置中datadir = /mysqldata/ 改为datadir = /mysqldata/data 重新初始化问题解决
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> show databases
-> ;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by 'root001';
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.10 sec)