Source installation mysql8.0.20

Install dependent libraries

yum -y install gcc gcc-c++ zlib zlib-devel ncurses ncurses-devel libaio libaio-devel

1. Download mysql8.0.20

wget https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-8.0.20-el7-x86_64.tar.gz

2. Unzip mysql

tar -zxf mysql-8.0.20-el7-x86_64.tar.gz

3. Create an installation directory

mkdir -p /usr/local/mysql/data

4. Create mysql process user

useradd mysql -s /sbin/nologin -M

5. Change the owner and group of the MySQL installation directory

chown -R mysql.mysql /usr/local/mysql/

6. Copy the downloaded mysql file to the installation directory

cp -r mysql-8.0.20-el7-x86_64/* /usr/local/mysql/

7. Switch to the msyql installation path and initialize

1. cd /usr/local/mysql
2. ./bin/mysqld --initialize --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
Note: After initialization , There will be a randomly generated root password at the end of the last line, please write it down! ! ! ! !

8. Configure the /etc/my.cnf file as follows

[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
#socket=/var/lib/mysql/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=/var/log/mysql-error.log
#pid-file=/var/run/mariadb/mariadb.pid
#include all files from the config directory
!includedir /etc/my.cnf.d

9, start mysql

/usr/local/mysql/support-files/mysql.server start

10. The first login to mysql will use the initial randomly generated root password and ask to change the password

Login: /usr/local/mysql/bin/mysql -uroot -p
Change password:
mysql> alter user'root '@'localhost' identified by '123456p';
Query OK, 0 rows affected (0.00 sec)
Refresh permissions:
mysql > flush privileges;
Query OK, 0 rows affected (0.00 sec)

Guess you like

Origin blog.51cto.com/6461704/2551958