mysql enable remote access privileges

Time:2024-3-26

1. Login to MySQL

mysql -u root -p


Enter your password

2. Select mysql database

use mysql;


Because the mysql database stores the user table with user information.

3. View information about the current root user in the user table of the mysql database.

select host, user, authentication_string, plugin from user; 


After executing the above command a table will be displayed

Check the host of the root user in the table, by default it should show localhost, which only supports local access and does not allow remote access.

4. Authorize all privileges for the root user and set up remote access.

update user set host='%' where user='root';


GRANT ALL ON means all permissions, % means all hosts are wildcarded and can access the remote.

5. Refresh Permission

After all operations, the

flush privileges;


6. Check the host of the root user

Execute step 2 again, you will see that the host of the root user has changed to %, which means that our modification has been successful and you can access it remotely now.
 

Recommended Today

[linux] Permission Understanding

catalogs 1. shell commands and how they work 2. The concept of authority 3. Authority management 2.1 Classification of document visitors (persons) 2.2 File types and access rights (thing attributes) 2.3 Representation of file permission values 2.4 Methods for setting file access rights 3. The file directive 4. Permissions for directories★ 5. Sticky bits★ 6. […]