How to remotely connect to mysql _ MySQL

Source: Internet
Author: User
For details about how to remotely connect to mysql authorization, bitsCN.com has a mysql database on the server and does not want to publish the root account. Therefore, a demo account is created, allow 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

Create user demo identified by 123456"

2,

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,

Mysql> FLUSH PRIVILEGES
// The modification takes effect.

4,

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:

MySQL> flush privileges;

Connect to MySQL administrator !! BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.