There are two main steps to implement remote login:
(1) Grant remote login permission to the mysql user (table modification method or authorization method);
(2) The firewall opens port 3306.
(1) Grant login permission
mysql -u root -p 输入密码进入到mysql中。
Authorization method
Create account test and authorize it, the password is password:
grant all on *.* to test@'127.0.0.1' identified by "password";
Free learning video tutorial sharing: mysql video tutorial
Change table method
1. Switch to mysql database:
USE mysql;
2. Modify test permissions:
UPDATE user SET host = '%' WHERE user = 'test';
%: Any IP can access
3. Check whether the user table has been modified successfully:
SELECT user,host FROM user;
4. Update the database:
flush privileges;
(2) Open port 3306
1. Check the firewall status:
[root@study ~]# firewall-cmd –state ## 结果显示为running或not running
2. Open the port:
## zone -- 作用域 ## add-port=80/tcp -- 添加端口,格式为:端口/通讯协议 ## permanent -- 永久生效,没有此参数重启后失效 firewall-cmd --zone=public --add-port=3306/tcp –-permanent
3. Restart the firewall
firewall-cmd --reload
Use firewall-cmd --help
to view the help file See more commands.
Recommended related articles and tutorials: mysql tutorial
The above is the detailed content of Implement mysql remote login under centos. For more information, please follow other related articles on the PHP Chinese website!