Add a remote connection account to MySQL

Source: Internet
Author: User

1. Log in to MySQL as an administrator

Mysql-u root-p

2. Select MySQL Database

Use MySQL

3. Create a user and set a password

Create user ' test ' @ ' localhost ' identified by ' 123456 '

4. Make the Operation effective

Flush Privileges

5. Make the Operation effective

Flush Privileges

6. Log in with a new user

Mysql-u test-p

Ways to allow users to access the database remotely

Workaround (It is recommended to use the second method for resolution):
1. Change the table method. It may be that your account is not allowed to log on remotely, only on localhost. This time, as long as the computer on the localhost, log in to MySQL, change the "MySQL" Database in the "User" table "host", from "localhost" to "%"

Mysql-u root-p

Mysql>use MySQL;

Mysql>update User Set host = '% ' where user = ' root ';

Mysql>select host, user from user;

2. Authorization law. For example, if you want to myuser use MyPassword to connect to a MySQL server from any host.

GRANT all privileges on * * to ' myuser ' @ ' percent ' identified by ' MyPassword ' with GRANT OPTION;


If you want to allow users to connect to the MySQL server from a host myuser IP 192.168.1.3 and use MyPassword as the password


GRANT all privileges on * * to ' root ' @ ' 192.168.1.3 ' identified by ' MyPassword ' with GRANT OPTION; (Only fixed IP login allowed)

PS: After you can use the new account remote link MySQL, a part of the small partners may also report a 2003 of the error, obediently quickly look at your server is not the firewall is not shut, not shut the words quickly gay off him

╭~~~╮
(O~.~o)

.

.

.

.

Hey, if you turn off the firewall or not, then it's the ultimate big trick.

Modify the default profile my.cnf in the bind-address, generally in the/etc directory, put this sentence before adding a # can be, OK perfect solution

Reprinted from http://blog.csdn.net/chr23899/article/details/40401089

Add a remote connection account to MySQL

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.