I have a mysql database on the server and remotely access it. I don't want to announce the root account. So I created a demo account that allows the demo account to access the shandong database in the mysql database anywhere.
Solution 1:
Run the following command on the machine where mysql is installed:
1: create a user
Copy codeThe Code is as follows: create user demo identified by "123456"
2,Copy codeThe Code is as follows: mysql> grant all privileges on shandong. * TO 'Demo' @ '%' WITH GRANT OPTION
// Grant the data access permission to any host. You can also perform the following operations:
Grant all privileges on shandong. * TO 'Demo' @ '%' identified by '000000' with grant option;
3,Copy codeThe Code is as follows: mysql> FLUSH PRIVILEGES
// The modification takes effect.
4,Copy codeThe Code is as follows: mysql> EXIT
// Exit the MySQL server so that you can log on to any other host as a demo.
Reference
In addition, when a client is used to connect to mysql, the connection fails. It seems that you need to re-authorize the user. The procedure is as follows:
[Root @ cicro108 mysql] # bin/mysql-uroot-p-h 127.0.0.1-A cws3
Enter password:
Welcome to the MySQL monitor. Commands end with or/g.
Your MySQL connection id is 1863 to server version: 4.1.20-standard
Type 'help; 'or'/H' for help. type'/C' to clear the buffer.
Mysql> grant all privileges on *. * to root @ "%" identified by "mysql ";
Query OK, 0 rows affected (0.17 sec)
After the permission is changed, the remote connection is still not available, but you can use the following operations.
Mysql> grant all privileges on *. * to root @ "%" identified by "mysql" with grant option;
Query OK, 0 rows affected (0.17 sec)
At this moment, the root user can be remotely connected. Of course, other non-root users can also be remotely connected here.
Solution 2:
MySQL 1130 error solution:
This error occurs when you connect to MySQL through MySQL-Front or MySQL administrator.
ERROR 1130: Host ***. *** is not allowed to connect to this MySQL server
This indicates that the connected user account does not have the permission for remote connection and can only log on to the Local Machine (localhost.
You need to change the host entry in the user table of the MySQL database.
Rename localhost as %
Specific steps: log on to MySQL
Use MySQL first;
An error occurs when the update method is provided by others.
MySQL> update user set host = '%' where user = 'root ';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'Primary'
Then, you can view the host information of the database as follows:
MySQL> select host from user where user = 'root ';
+ ----------------------- +
| Host |
+ ----------------------- +
| % |
| 127.0.0.1 |
| Localhost. localdomain |
+ ----------------------- +
3 rows in set (0.00 sec)
The host already has the value %, so run the following command:Copy codeThe Code is as follows: MySQL> flush privileges;
Connect to MySQL administrator !!