This article is still xftp gz files to upload, and then operate on xShell, if not installed and used before please refer to these two files blog.
1. The downloaded file is uploaded to a position corresponding with xftp.
2. Unzip the file: tar -zvxf MySQL-5.7.28-Linux-glibc2.12-x86_64.tar.gz
3. In the / usr / local build folder mysql folder
mkdir /usr/local/mysql
4. The decompressed mysql text is moved to the / usr / local / mysql follows:
mv mysql-5.7.28-linux-glibc2.12-x86_64/* /usr/local/mysql
5 is centos add mysql user groups and mysql user (-s / bin / false parameter specifies mysql user ownership only, without login privileges ) , respectively, at both ends of the code execution. By ll (lowercase L) View mysql privileges
groupadd mysql useradd -r -g mysql -s /bin/false mysql
6. Go to the / usr / local / mysql folder under:
cd /usr/local/mysql
7. Check MySQL to find the path to the configuration file, the more left-first search:
./bin/mysql --help | grep 'Default options' -A 1
8. Create a configuration file:
rm -rf /etc/my.cnf touch /etc/my.cnf
9. Edit the my.cnf file:
we /etc/my.cnf
10. Press i to start editing the file; in adding /etc/my.cnf in:
[mysqld] Port = 3306 DATADIR = / var / lib / MySQL / Data Socket = / var / lib / MySQL / Data / mysql.sock User = the root max_connections = 151 symbolic-links = 0 # Ignored case lower_case_table_names. 1 = # specified encoding Character-Server-SET = UTF8 collation = utf8_general_ci-Server # file specified client socket communication path connecting MySQL
[client]
socket = / var / lib / MySQL / Data / mysql.sock
11. Copy the mysql startup script to the resource directory, so you can start anywhere mysql
cp ./support-files/mysql.server /etc/rc.d/init.d/mysql
12. The increase mysqld service control script execute permissions
chmod +x /etc/rc.d/init.d/mysql
13. The mysql service is added to the system services
chkconfig --add mysql
14. Check the mysql if the service is already in force
chkconfig --list mysql
15. Create mysql specified folder:
mkdir / var / lib / mysql / mkdir / var / lib / mysql / data
16. By the owner and group chown change file, -R processing of all files in the specified directory and its subdirectories:
chown -R mysql:mysql /var/lib/mysql/
17. Installation mysql
mysqld --user=root --basedir=/usr/local/mysql --datadir=/var/lib/mysql/data --initialize
After a successful installation, you need to pay attention to the last line: # WQ.os6 <wwk to mysql random password?
2019-10-27T01:28:32.711916Z 1 [Note] A temporary password is generated for root@localhost: #WQ.os6?<wwk
18. Start mysql:
service mysql start
19. The configuration environment variable:
vi / etc / profile at the end add: Export the PATH = $ the PATH: / usr / local / MySQL / bin
20. Refresh environment variable file:
source /etc/profile
21. Modify Password: Enter the password:
mysql> alter user 'root' 'I want to change the password of' @ 'localhost' IDENTIFIED by; MySQL> flush privileges; MySQL> quit;
22. Restart mysql:
service mysql restart
23. The remote access configuration, the firewall port settings, for remote access:
firewall-cmd --zone=public --add-port=3306/tcp --permanent firewall-cmd --reload
24. After configuration, you can view open remote port:
firewall-cmd --list-port
25. Set permissions to allow remote connection to the database:
update mysql.user set user.Host='%' where user.User='root';
Refresh permissions:
flush privileges;
26. The test for whether ip can use remote links (my linux's IP is 192.168.189.150):
./bin mysql -u root -p -h192.168.189.150
If you enter the password can connect mysql. That is, the instructions to install mysql on centos success! ! !