MySQL add remote user or allow remote access three ways

Source: Internet
Author: User
Tags flush mysql tutorial

MySQL tutorial add a remote user or allow remote access to three ways

Log in with the root user, and then:

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

Flush privileges; * Refresh the content just now *

Format: Grant permission on database tutorial name. table name to user @ Login host identified by "User password";

@ The client IP address (or hostname) that accesses MySQL is followed by any client, if the localhost is filled

Local access (that user will not be able to access the MySQL database remotely).

You can also set whether or not you have remote access permissions for existing users. As follows:

Use MySQL;

Update db Set host = '% ' where user = ' username '; (If written as host=localhost, this user does not have remote access permission)

Flush privileges;

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

Method Two

1. Add using the GRANT statement: first use root on database native

Login to MySQL (I am using remote Control Linux server, equivalent to login on the server native to MySQL), and then enter:

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

Add a user admin and authorize access via local machine (localhost), password "something".

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

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

2. Use INSERT statement:

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

' Y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y '

User information can be viewed in the users table in the MySQL database, which is not covered here. Count the number of Y, OH.

OK, use the Admin account connection to try, I was repeatedly tried repeatedly success Oh, hehe!

Method Three

Add remote user admin password to 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


As a result of project development requirements Database design has to use remote mode. However, the remote settings for the database are not that simple, and the project's database is mysql5.0. Just started to think that as long as the database server can be used for remote links, but the MySQL settings are for the user's security, the system default setting is not allow remote users to connect, only local users. As long as we set the system administrator user's host this value can be given to the remote user access.

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.