Home > Database > Mysql Tutorial > Implement mysql remote login under centos

Implement mysql remote login under centos

王林
Release: 2020-01-26 20:40:39
forward
3577 people have browsed it

Implement mysql remote login under centos

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中。
Copy after login

Authorization method

Create account test and authorize it, the password is password:

grant all on *.* to test@'127.0.0.1' identified by "password";
Copy after login

Free learning video tutorial sharing: mysql video tutorial

Change table method

1. Switch to mysql database:

USE mysql;
Copy after login

2. Modify test permissions:

UPDATE user SET host = '%' WHERE user = 'test';
Copy after login

%: Any IP can access

3. Check whether the user table has been modified successfully:

SELECT user,host FROM user;
Copy after login

Implement mysql remote login under centos

4. Update the database:

flush privileges;
Copy after login

(2) Open port 3306

1. Check the firewall status:

[root@study ~]# firewall-cmd –state       ## 结果显示为running或not running
Copy after login

2. Open the port:

## zone -- 作用域
## add-port=80/tcp -- 添加端口,格式为:端口/通讯协议
## permanent -- 永久生效,没有此参数重启后失效
firewall-cmd --zone=public --add-port=3306/tcp –-permanent
Copy after login

3. Restart the firewall

firewall-cmd --reload
Copy after login

Implement mysql remote login under centos

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!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template