Under Linux mysql creates a new account and sets the permissions
- 2020-05-13 03:40:58
- OfStack
1. Authorization
Note: mysql is deployed on the server A, and the host B on the Intranet connects to the server A through the client tool for database operation. It requires the server A to grant the host B permission to operate mysql
1.1 enter mysql on server A, and assume that mysql's account on server A is root:
Then hit enter and type in your password!
1.2 grant the host B permission to operate the database
Note: give username@192.168.0.1 the permission to use all the databases. Log in with the username account on host 192.168.0.1 and the password is password
Note: give username@192.168.0.1 the highest authority to operate newdb database, and use username account on host 192.168.0.1 to log in without password
For example:
Note: give root@192.168.0.1 permission to use all databases, and use root account on host 192.168.0.1. Password: 123456
2. Remove your account
Note: account root has been removed so that host 192.168.0.1 can no longer use the root user to operate the database on the server A
Note: mysql is deployed on the server A, and the host B on the Intranet connects to the server A through the client tool for database operation. It requires the server A to grant the host B permission to operate mysql
1.1 enter mysql on server A, and assume that mysql's account on server A is root:
mysql - u root -p
Then hit enter and type in your password!
1.2 grant the host B permission to operate the database
mysql> grant usage on *.* to username@192.168.0.1 identified by 'password';
Note: give username@192.168.0.1 the permission to use all the databases. Log in with the username account on host 192.168.0.1 and the password is password
mysql> grant all privileges on newdb.* to username@192.168.0.1;
Note: give username@192.168.0.1 the highest authority to operate newdb database, and use username account on host 192.168.0.1 to log in without password
For example:
mysql> grant all privileges on *.* to root@192.168.0.1 identified by '123456' ;
Note: give root@192.168.0.1 permission to use all databases, and use root account on host 192.168.0.1. Password: 123456
2. Remove your account
mysql> drop user root@192.168.0.1;
Note: account root has been removed so that host 192.168.0.1 can no longer use the root user to operate the database on the server A