1. Turn on remote control
MySQL does not enable remote control by default, and you must add a remote access user, that is, you can only access it by yourself by default, and other machines cannot access it.
1.1. Connect to the server:
mysql -u root -p
1.2. View all current databases:
show databases;
1.3. Enter the mysql database:
use mysql;
1.4. View all tables in the mysql database:
show tables;
1.5. View the data in the user table:
select Host, User from user;
1.6. Modify the Host in the user table:
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘root’ WITH GRANT OPTION;
Note: % stands for any client and can be replaced with a specific IP address.
1.7. Finally refresh:
flush privileges;
Note: Be sure to remember to add ";" after the statement is completed when writing sql