There are many versions of Linux, so when downloading MySQL, it is important to download the MySQL database file corresponding to the Linux version. The following methods are also suitable for installing the MySQL 5.7.* version of CentOS 7. The installation method I organized into 16 steps.
1: Download centOS7 corresponding MySQL version (general version of generic)
[Email protected] soft]# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
Baidu Cloud share Download: Http://pan.baidu.com/s/1eSiXD6M
2: Create a new MySQL directory under/usr/local/
[Email protected] local]# Touch/usr/local/mysql
3: Unzip the file into the MySQL directory
[Email protected] soft]# TAR-XVF mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz-c/usr/local/mysql
4: Check whether the library files are deleted, if any, delete (Linux system comes with)
[Email protected] mysql]# Rpm-qa | grep MySQL
Delete
[Email protected] mysql]# rm-e–-nodeps mysql-libs-5.1.52.x86_64
(I'm having trouble querying the library file but can still delete it)
5: Check whether the MySQL group and the user exist, such as no create
[Email protected] ~]# Cat/etc/group | grep MySQL
mysql:x:490:
[[email protected] ~]# cat/etc/passwd |grep MySQL
Mysql:x:496:490::/home/mysql:/bin/bash
These are the default conditions, such as none, to execute the Add command:
[[Email protected] ~] #groupadd MySQL
[[Email protected] ~] #useradd-R-G MySQL MySQL
The Useradd-r parameter indicates that the MySQL user is a system user and cannot be used to log on system
6: Add the data directory under MySQL
[Email protected] mysql]# mkdir data
7: Change all directories and folders under the MySQL directory to belong to the combined user
[Email protected] ~]# cd/usr/local/
[Email protected] local]# chown-r MySQL mysql/
[Email protected] local]# chgrp-r MySQL mysql/
[Email protected] local]# CD mysql/
[Email protected] local]# ls-l
(You can see that the original group and the user root have been modified to MySQL after successful modification.)
8: Install and initialize the database
(1)
[Email protected] mysql]# bin/mysql_install_db--user=mysql--basedir=/usr/local/mysql/--datadir=/data/mysql/
(2)
Next, go to the/usr/local/mysql/support-files/directory.
See if a my-default.cnf file exists, if there is a direct copy to the/etc/my.cnf file
[Email protected] mysql]# cp-a./support-files/my-default.cnf/etc/my.cnf
If the my-default.cnf file does not exist
The MY.CNF is created under the/etc/directory
Write in File
[HTML]View PlainCopy
- #[mysql]
- #basedir=/usr/local/mysql/
- #datadir=/data/mysql/
(3)
[Email protected] mysql]# CD bin/
[Email protected] bin]#/mysqld_safe--user=mysql &
9: Start MySQL
[[Email protected] bin]# service MySQL start or [[email protected] bin]# systemctl start Mysqld.service
[Email protected] bin]#/etc/init.d/mysqld restart
10: Set Boot from boot
[Email protected] bin]# chkconfig--level mysqld on
11: Log in to MySQL
[Email protected] bin]#/mysql-u root-p
Enter Password:
(Here the password to see the 12th step)
12: Check the system auto-generated password
[Email protected] bin]# Cat/root/.mysql_secret
# Password set for user ' [e-mail protected] ' at 2017-08-13 16:54:06
0#n)? iduvhot
13: Modify MySQL Password
Mysql> set Password=password (' root ')
14: Telnet permission
Mysql> Grant all privileges on * * to ' root ' @ '% ' identified by ' root ';
mysql> flush Privileges;
Mysql> quit
15: Open Port 3306
[Email protected] ~]# firewall-cmd--permanent--zone=public--add-port=3306/tcp
[Email protected] ~]# Firewall-cmd--reload
[Email protected] ~]# Firewall-cmd--query-port=3306/tcp
16: Modify MySQL No access off MySQL time (default 8 hours) [This step no need to ignore]
Inquire
Mysql> show global variables like ' wait_timeout ';
Modify
mysql> set global wait_timeout=388000;
End can now log in remotely
MySQL 5.7.19 CentOS 7 Installation