mysql remote login

After installing mysql on CentOS7, mysql want to implement remote login.

Mainly to solve two problems: (1) to grant remote logon rights (to change the law or table Authorization Act) for the mysql user; (2) an open firewall port 3306.

(A) login privileges

mysql -u root -p Enter the password to enter the mysql.

Authorization Act

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

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

Change table method

1. Switch to mysql database:

USE mysql;

2. Modify the permissions of test:

UPDATE user SET host = '%' WHERE user = 'test';

% : No ip can be accessed

3. Check the user table is modified successfully:

SELECT user,host FROM user;

image

4. Update the database:

flush privileges;

(B) open port 3306

1. Check the firewall status:

[Root @ study ~] # firewall-cmd -state ## results are shown as running or not running

2. Open the port:

## zone - Scope

## add-port = 80 / tcp - Add Port following format: port / protocol

## permanent - permanent, this argument does not restart after failure

firewall-cmd --zone=public --add-port=3306/tcp –-permanent

3. Restart the firewall

firewall-cmd --reload

image

Use firewall-cmd --help to view the help file for more commands.

Guess you like

Origin www.cnblogs.com/riter-xu/p/12233458.html