Remote connection Mysql Licensing method detailed _mysql

Source: Internet
Author: User
Today, there is a MySQL database on the server, remote access, do not want to disclose the root account, so, create a demo account, allow demo account anywhere can access the MySQL database Shandong Library.
programme I
Running on a MySQL-installed machine:
1: Create user users
Copy Code code as follows:

CREATE USER Demo identified by "123456"

2,
Copy Code code as follows:

Mysql>grant all privileges in shandong.* to ' demo ' @ '% ' with GRANT OPTION
Give any host access to data, or you can do the following
Grant all privileges in shandong.* to ' demo ' @ '% ' identified by ' 123456 ' with Grant OPTION;

3,
Copy Code code as follows:

Mysql>flush Privileges
Change takes effect

4,
Copy Code code as follows:

Mysql>exit
Exit the MySQL server so that you can log on as a demo on any other host

Reference
In addition, when you connect to MySQL with the client, you find that you cannot connect, and it appears that you need to authorize the user. The operation 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 discovering this change of permissions, the remote still cannot connect, but with the following action is OK.
Mysql> grant all privileges in *.* to root@ '% ' identified by ' MySQL ' with Grant OPTION;
Query OK, 0 rows affected (0.17 sec)
At this point, root can be remotely connected, and, of course, other non-root users can be connected remotely.

Programme two
MySQL 1130 Error Resolution:
This error occurred while connecting to MySQL via Mysql-front or MySQL administrator
ERROR 1130:host ***.***.***.*** is isn't allowed to connect to this MySQL server
Indicates that the connected user account does not have remote connection permissions and can only log on as a native (localhost).
You need to change the host item in the user table in the MySQL database
Rename localhost to%

Specific steps: Login to MySQL
Use MySQL first;
An error occurs when you update in the way others provide.
mysql> Update user set host= '% ' where user = ' root ';
ERROR 1062 (23000): Duplicate entry '%-root ' for key ' PRIMARY '
We then looked at the host information for the following 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)
Host already has the% value, so run the command directly:
Copy Code code as follows:

Mysql>flush privileges;

Then use the MySQL administrator to connect ... Success!!

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.