MYSQL adds remote users or allows remote access.

Source: Internet
Author: User
Tags mysql tutorial

MYSQL adds remote users or allows remote access.
Add the remote user admin password as password grant all privileges on *. * TO admin @ localhost identified by \ 'password \ 'with grant option grant all privileges on *. * TO admin @ \ "% \" identified by \ 'password \ 'WITH GRANT OPTION

Add a remote user or allow remote access in the mysql tutorial

Log On with the root user, and then:

Grant all privileges on *. * to create the username @ "%" identified by "password ";

Flush privileges; * refresh the content just now *

Format: grant permission on Database tutorial name. Table name to user @ login host identified by "User Password ";

@ Followed by the IP address (or host name) % of the client accessing mysql represents any client. If you enter localhost

Local access (this user cannot remotely access the mysql database ).

You can also set the remote access permission for existing users. As follows:

Use mysql;

Update db set host = '%' where user = 'username'; (if the name is host = localhost, this user does not have the remote access permission)

Flush privileges;

Grant all privileges on *. * to 'myuser' @ '%' identified by 'mypassword' with grant option;

 

 

Method 2

1. Add using the grant statement: first, use the root user on the local database.

Log on to mysql (I remotely control the linux server, which is equivalent to logging on to mysql on the server) and enter:

Mysql> grant all privileges on *. * to admin @ localhost identified by 'something' with grant option;

Add a user admin and authorize access through localhost with the password "something ".

Mysql> grant all privileges on *. * to admin @ "%" identified by 'something' with grant option;

Add a user admin and authorize access initiated from any other host (wildcard % ). Use this statement.

2. Use the insert statement:

Mysql> insert into user values ('%', 'admin', password ('something'), 'y ', 'y', 'y ',

'Y', 'y ')

User information can be viewed in the users table of the mysql database. Count the number of y.

Okay. Try using the admin account. I have tried and tried multiple times successfully!

Method 3

Add the remote user admin password as password
Grant all privileges on *. * to admin @ localhost identified by 'Password' with grant option
Grant all privileges on *. * to admin @ "%" identified by 'Password' with grant option


Because of the requirements of project development, the database design has to use the remote mode. However, the remote settings of the database are not that simple. The database of this project is mysql5.0. At the beginning, I thought that a remote connection can be performed as long as the database server is installed. However, mysql is set for user security. The default system setting is that remote user connection is not allowed, only Local Users can be connected. You only need to set the host value of the system administrator user to allow remote access.


Which of the following methods does MySQL not allow remote access?

Solution:

1. Change the table.

It may be that your account is not allowed to log on remotely, but only on localhost. At this time, you only need to log in to mysql on the computer of localhost, and change the "host" entry in the "user" table in the "mysql" database to "%" from "localhost"

Mysql-u root-pvmwaremysql> use mysql;

Mysql> update user set host = '%' where user = 'root ';

Mysql> select host, user from user;

2. Authorization method.

For example, if you want myuser to use mypassword to connect to the mysql server from any host.

Grant all privileges on *. * TO 'myuser' @ '%' identified by 'mypassword' with grant option;

Flush privileges;

If you want to allow myuser to connect to the mysql server from a host whose ip address is 192.168.1.6, and use mypassword as the password

Grant all privileges on *. * TO 'myuser' @ '192. 168.1.3 'identified BY 'mypassword' with grant option;

Flush privileges;

If you want to allow myuser to connect to the dk database of the mysql server from a host with ip address 192.168.1.6, and use mypassword as the password

Grant all privileges on dk. * TO 'myuser' @ '192. 168.1.3 'identified BY 'mypassword' with grant option;

Flush privileges;

I used the first method. I first found that it could not work. I checked it online and executed one less statement mysql> FLUSH RIVILEGES to make the modification take effect.

Another method, but I have not tried it myself. You can find it on csdn.net.

Run the following command on the machine where mysql is installed:

1. d: \ mysql \ bin \> mysql-h localhost-u root // enter the MySQL server.

2. mysql> grant all privileges on *. * TO 'root' @ '%' with grant option // GRANT data access permissions TO any host

3. mysql> flush privileges // The modification takes effect.

4. mysql> EXIT // EXIT the MySQL server

In this way, you can log on to any other host as the root user!
Reference: Shanghai Express network... the remaining full text>

How can I allow remote access to the mysql database? Is to connect mysql on my computer from another computer

1. Change the "host" entry in the "user" table in the "mysql" database and rename it '%' from "localhost '.
Or Add a new record. "host" is the IP address to be accessed and authorized. Restart the mysql service.
2. Add the exception port 3306 to the system firewall and allow the exception.

Error message:
ERROR 1130: Host '192. 168.1.3 'is not allowed to connect to this MySQL server
Solution:
1. Change the table. It may be that your account is not allowed to log on remotely, but only on localhost. At this time, you only need to log in to mysql on the computer of localhost, and change the "host" entry in the "user" table in the "mysql" database to "%" from "localhost"
1. mysql-u root-pvmware
Mysql> use mysql;
Mysql> update user set host = '%' where user = 'root ';
Mysql> select host, user from user;

2. Authorization method. For example, if you want myuser to use mypassword to connect to the mysql server from any host.

Grant all privileges on *. * TO 'myuser' @ '%' identified by 'mypassword' with grant option;
If you want to allow myuser to connect to the mysql server from a host whose ip address is 192.168.1.3, and use mypassword as the password
Grant all privileges on *. * TO 'myuser' @ '192. 168.1.3 'identified BY 'mypassword' with grant option;

3. Add port 3306 in the Windows Firewall

Summary:
Mysql-u root-p
Mysql> use mysql;
Mysql> select 'host' from user where user = 'root ';
Mysql> update user set host = '%' where user = 'root ';
Mysql> flush privileges;
Mysql> select 'host' from user where user = 'root ';
The first sentence is to authorize the User root to log on.
Second sentence: Select mysql database
Third sentence: view the host value of the user table in the mysql database (the host/IP name that can be accessed through connection)
Fourth sentence: Modify the host value (add host/IP address with the wildcard % content), of course, you can also directly add IP addresses
Fifth sentence: refresh the MySQL system permission table
The sixth statement is modified when you re-view the user table ..
Restart the mysql service .... Remaining full text>

Related Article

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.