MySQL can be connected using localhost, but cannot be connected using IP _ MySQL

Source: Internet
Author: User
MySQL can be connected using localhost, but cannot be connected using IP addresses.

Problems frequently encountered during java web Development: mysql can only be connected using localhost or 127.0.0.1

Solution: After mysql is installed, it is the root user by default. the root user can only log on to the server and needs to be assigned a new user.

1. log on to the mysql database as the root user.

2. run the following command to assign a new user:

Grant all privileges on *. * to 'username '@ 'IP Address 'identified by 'password ';

'All privileges': all permissions can also be written as select, update, and so on.
*. * All tables in all databases, such as databasename .*.
The IP address of the IP database.
Identified by 'password' indicates a password connection.

3. run the preceding command to refresh the permission.

Flush privileges;

4. modify my. conf configuration

[Mysqld]... bind_address = 127.0.0.1 # Block this...

5. restart mysql

5. 1. stop: Enter

sudo /etc/init.d/mysql stop

5. 2. start: Enter

sudo /etc/init.d/mysql start

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.