How to realize mysql remote login in centos system
There are two main steps to implement remote login:
(1) grant remote login rights to mysql users (table modification or authorization method)
(2) the firewall opens port 3306.
(1) granting login authority
Mysql-u root-p enter the password into the mysql.
Authorization law
Create an account test and authorize it. The password is password:
Grant all on *. * to test@'127.0.0.1' identified by "password"
Table change method
1. Switch to the mysql database:
USE mysql
two。 Modify the permissions of test:
UPDATE user SET host ='% 'WHERE user =' test'
%: any ip can be accessed
3. Check whether the user table has been modified successfully:
SELECT user,host FROM user
4. Update the database:
Flush privileges
(2) opening port 3306
1. View firewall status:
[root@study ~] # firewall-cmd-state # # results are displayed as running or not running
two。 Open the port:
# # zone-- scope # # add-port=80/tcp-- add a port in the format: Port / communication protocol # # permanent-- permanently effective. Firewall-cmd-- zone=public-- add-port=3306/tcp-- permanent expires after restart without this parameter
3. Restart the firewall
Firewall-cmd-reload
Use firewall-cmd-- help to view the help file to see more commands.
The above are the details of mysql remote login under centos, please pay attention to other related articles!