MySQL Open Telnet method introduction

Source: Internet
Author: User
Tags flush
The code is as follows Copy Code

Mysql-u root-p
mysql> use MySQL;
Mysql> grant all privileges in *.* to root@ '% ' identified by ' root ';
Mysql> select Host,user,password from user;

+ ———— –+--+ ——————————————-+
| Host | user | password |
+ ———— –+--+ ——————————————-+
| localhost | Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b |
| 192.168.1.12 | Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b |
| %            | Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b |
+ ———— –+--+ ——————————————-+
3 Rows in Set (0.00 sec)

mysql> flush Privileges;

Authorization law:

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

The code is as follows Copy Code

Mysql> grant all privileges in *.* to identified by ' MyPassword ' with GRANT OPTION;

If you want to allow the user to connect to the MySQL server from the IP-192.168.1.6 host, and use MyPassword as the password myuser

The code is as follows Copy Code

Mysql> grant all privileges in *.* to ' myuser ' @ ' 192.168.1.3′identified by ' mypassword ' with GRANT OPTION;


Attention:
1, Format: Grant permissions on the database name. Table name to user @ Login host identified by "User password";
2, is the new root is not modified, if the localhost to%, then the local can not connect to the MySQL through localhost;
3, refresh the MySQL system permissions related table flush privileges;

More relevant open MySQL remote connection can refer to: http://www.111cn.net/database/mysql/34989.htm

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.