Linux MySQL database open external access settings guide

Source: Internet
Author: User

Linux settings MySQL and allow external machine access, the specific directory is the case, some people are installed in the personal directory, then find the corresponding directory can be Linux under set MySQL and allow external machine access sudo vi/etc/my.cnf
The specific directory is the case, some people are installed in the personal directory, the corresponding directory can be found.
One, the configuration file modification
1. #sudo vim/etc/mysql/my.conf
Find bind-address = 127.0.0.1
Comment out this sentence
second, the MySQL database modification
1) [[email protected] etc]# mysql-u root-p
Enter Password:
2) Grant all privileges the database.* to [e-mail protected] identified by ' password '
Attention:
(1) 192.168.1.1 is the IP address of the client that wants to connect to this MySQL database, not the IP address of the database server where the MySQL database resides, remember
(2) password is the MySQL database root user's password, according to the actual situation needs to modify

How do I access the MySQL database on a Linux system?
Shortly before the MySQL database was installed in the Linux system, but the Linux system was a virtual machine, and the real host was Win7, I tried to access the MySQL database under the Linux system using MySQL Database Tools under Win7. However, there was a problem during the connection:
Host ' 192.168.0.101 ' isn't allowed to connect to this MySQL server
Then I Baidu a bit this problem, found the following several solutions.

Method One: (Modify table)
Enter the MySQL database under the Linux system, open the user table, find the "Host" field value "localhost" record, and update the value "localhost" to "%".
The command is as follows:
#mysql-U root-p
Enter Password:
Mysql>use MySQL;
Mysql>update user set host= '% ' where user= ' root ' and host= ' localhost ';
Mysql>select host,user from user; 

Method Two: (authorization)  
Example 1 
If you want to myuser use MyPassword from any host to connect to the MySQL database server. Use the following authorization command:  
GRANT all privileges on *. * to [email= ' myuser ' @ '% ']%27myuser %[email protected]%27%%27[/email] identified by ' MyPassword ' with GRANT OPTION;  
Example 2 
If you want to allow the user to connect to the MySQL database server myuser the host from IP 192.168.0.101 and use MyPassword as the password. Use the following authorization command:  
GRANT all privileges on *. * to [email= ' myuser ' @ ' 192.168.0.101 ']%27myuser%[email protected]%27192.168.0.101%27[/email] identified by ' MyPassword ' with GRANT OPTION; 
The above two methods are found on the Internet. I use the second method in example 1 to solve the problem I encountered, and successfully connected to the Linux system MySQL database server.

Linux MySQL database open external access settings guide

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.