Authorization method command for MYSQL remote login

  • 2020-05-12 06:19:06
  • OfStack

Method 1. Log in mysql locally, change the "host" item in the "user" table in the "mysql" database, and change "localhost" to "%"

#mysql -u root -proot
mysql > use mysql;
mysql > update user set host = '%' where user = 'root';
mysql > select host, user from user;

Method 2. Direct authorization (recommended)

Connect to mysql server from any host using root user, password: youpassword (your root password) :

# mysql -u root -proot
mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;
Permitted address 202.11.10.253 root user and password to connect mysql dboomysql all database, pay select, insert, update, delete permissions.

# mysql -u root -proot
grant select,insert,update,delete on *.* to root@"202.11.10.253" Identified by "dboomysql";
Allow root user and password dboomysql to connect to all databases of mysql at address 202.11.10.253 and pay all permissions.

# mysql -u root -proot

grant all on *.* to root@"202.11.10.253" Identified by "dboomysql"

Do the following command to refresh permissions after the operation

FLUSH PRIVILEGES

Related articles: