- 首先。要有软件包mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
- [root@bogon ~]#yum -y install libaio
- [root@bogon ~]#tar zxf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local
- [root@bogon ~]# cd /usr/local/
- [root@bogon local]# mv mysql-5.7.24-linux-glibc2.12-x86_64/ mysql
- [root@bogon local]# useradd -M -s /sbin/nologin mysql
- [root@bogon local]# cd mysql/
- [root@bogon mysql]# chown -R mysql:mysql ./
- [root@bogon mysql]# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
- [Note] A temporary password is generated for root@localhost: ho19hx,%sZNq
记住上面这一行的密码。这个是初始密码。每一台机器的初始密码都不一样。
10. 修改/etc/my.cnf文件。(因为我们的mysql安装在/usr/local/下的,所以需要重新定义)
[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/usr/local/mysql/data/mysql.log
pid-file=/usr/local/mysql/data/mysql.pid
到这一步其实就已经做完了,后面的都是起服务跟优化
11. [root@bogon mysql]# ./support-files/mysql.server start
12 . [root@bogon mysql]# netstat -anpt |grep 3306
13. [root@bogon mysql]# cp support-files/mysql.server /etc/init.d/mysqld
14. [root@bogon mysql]# service mysqld restart
15. [root@bogon mysql]# ./bin/mysqladmin -u root -p password '123123'
16. [root@bogon mysql]# ln -s /usr/local/mysql/bin/* /usr/local/bin
17. [root@bogon mysql]#service mysql restart