wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
# 其他版本见:http://mirrors.sohu.com/mysql/MySQL-5.7/
[root@node0 ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@node0 ~]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
[root@node0 ~]# rpm -qa | grep mysql
[root@node0 ~]#
[root@node0 setups]# tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
# 创建快捷方式
[root@node0 setups]# cd /usr/local/ && mv mysql-5.7.17-linux-glibc2.5-x86_64/ mysql
[root@node0 local]# cd mysql/support-files/
[root@node0 support-files]# cp my-default.cnf /etc/my.cnf
[root@node0 support-files]# vim /etc/my.cnf
# 修改 字符编码,默认引擎
[mysql]
default-character-set=utf8mb4
[mysqld]
default-storage-engine=INNODB
character_set_server=utf8mb4
collation_server=utf8mb4_unicode_ci
basedir=/usr/local/mysql
datadir=/home/mysql_data
# 这里设置的端口是13306
port=13306
[root@node0 support-files]# cp mysql.server /etc/init.d/mysql
[root@node0 support-files]# vim /etc/init.d/mysql
# 配置存储路径等
basedir=/usr/local/mysql
datadir=/home/mysql_data
[root@node0 support-files]# groupadd mysql
[root@node0 support-files]# useradd -r -g mysql mysql
[root@node0 support-files]# passwd mysql
[root@node0 support-files]# chown -R mysql:mysql /usr/local/mysql/
[root@node0 support-files]# chown -R mysql:mysql /home/mysql_data/
[root@node0 support-files]# cd /usr/local/mysql/bin/
[root@node0 bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/home/mysql_data
2018-07-21T07:53:44.624633Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-07-21T07:53:44.624672Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2018-07-21T07:53:44.624675Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2018-07-21T07:53:45.572491Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-07-21T07:53:45.702139Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-07-21T07:53:45.773027Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 31d6be7c-8cbb-11e8-8503-8cec4b82d3fa.
2018-07-21T07:53:45.776551Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-07-21T07:53:45.778592Z 1 [Note] A temporary password is generated for root@localhost: ?&Sj)BqHa6+6
# 上一行最后的 ?&Sj)BqHa6+6 就是临时密码
[root@node0 bin]# ./mysql_ssl_rsa_setup --datadir=/home/mysql_data
[root@node0 bin]# ./mysqld_safe --user=mysql &
# 检查启动成功
[root@node0 bin]# ps -ef|grep mysql
# 有进程就说明启动成功
[root@node0 bin]# ./mysql -uroot -p
Enter password: # 这里键入 刚才的临时密码 笔者是 ?&Sj)BqHa6+6
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
# 遇到上述 mysql> 代表登陆成功。
# 笔者将mysql root账号的密码改为 root1234
mysql> set password=password('root1234');
# 同时将允许远程连接,注意下一行最后需要填密码
mysql> grant all privileges on *.* to root@'%' identified by 'root1234';
mysql> flush privileges;
[root@node0 bin]# firewall-cmd --zone=public --add-port=13306/tcp --permanent
[root@node0 bin]# firewall-cmd --reload
[root@node0 bin]# chkconfig --add mysql
[root@node0 bin]# chkconfig mysql on
vim /etc/profile