MySQL database can be accessed remotely or by IP address.

Source: Internet
Author: User

MySQL database can be accessed remotely or by IP address.

  In general, it is not recommended to directly modify root permissions, 

First look at the user-level permissions of your MySQL database

Mysql-u root-p-----> Login with Root

Use MySQL-------> switch to mysql database (this MySQL is the name of the database,----> Install the system comes with it)

  

Can see mine is this, as to why there are 2 root I am not quite clear, I remember when the MySQL installation has an option is---(whether remote access) may be the first root is the role of it, and we commonly used is the 2nd root. WLS is my new user, this user can be logged in with an IP address.

Specific creation process:

Method One:

1, we now add a ' WLS ' user, password for ' Ybsoft ', so that it can access MySQL from outside. Input
Grant all on * to ' WLS ' identified by ' ybsoft ';

2. Now look at the contents of the user table. Enter select User,host from user; You can see that the "WLS" user has been added, and its permissions are '% '.

3, we can now use WLS users in the local area network or the Internet to access the IP.

Mysql-h 192.168.0.115-u Wls-p

4. FLUSH Privileges//modification takes effect

5, bind-address= 127.0.0.1 comments out can be------> found in the My.ini bind-address=0.0.0.0 is all the IP address can access, or do not have this attribute, the specific circumstances of their own try to know.

Method Two:

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;

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;

FLUSH privileges;

If you want to allow users to connect to the MySQL server from a host myuser IP 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 users to connect to the MySQL server's DK database myuser from the IP-192.168.1.6 host, and use MyPassword as the password

GRANT all privileges the dk.* to ' myuser ' @ ' 192.168.1.3 ' identified by ' MyPassword ' with GRANT OPTION;

FLUSH privileges;

    

  

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.