About MySQL Database remote access

Source: Internet
Author: User
Tags access database iptables

MySQL database installation defaults to local access only, if you need remote connection to do something according to different operating system

Windows:

The newly installed MySQL cannot log on locally and is displayed as a 1045 error

mysql#1045 (1045Access denied for user ' root ' @ ' localhost ' (using Password:yes)

Workaround: Modify the MySQL database configuration file My.ini and add a line below [mysqld] Skip-grant-tables

The MySQL database can be successfully accessed locally, but cannot be accessed remotely

Modify user rights on this machine, default is localhost for%

In the MySQL database user table, change localhost directly to "%",

UPDATE USER SET host= '% ' WHERE user= ' admin ';

Or add a row host to "%", set password to access database password consistent

UPDATE USER SET password=password (' baihong159753 ') WHERE host= '% ' and

user= ' admin ';

If remote access is still not available, you must modify the MySQL database configuration file My.ini

Add a line under [mysqld] This skip-name-resolve means: ignore the way the host name is accessed

Lower_case_table_names=1, which means: ignore the case in the database, this line can be added without

Ubuntu:

Step 1:

Vim/etc/mysql/my.cnf Found bind-address = 127.0.0.1

Comment out this line, such as: #bind-address = 127.0.0.1

or instead: Bind-address = 0.0.0.0 Allow any IP access, or specify an IP address yourself.

Restart Mysql:sudo/etc/init.d/mysql restart

Step 2:

The user's host in the MySQL database user table is changed to%

Centos:

Mysql>use MySQL;

Mysql>update user set host= '% ' where host= ' localhost ';

Mysql>flush privileges; # Overloaded System permissions

Allow Port 3306

    1. Iptables-i input-p tcp-m State--state new-m TCP--dport 3306-j ACCEPT
    2. /etc/init.d/iptables Save
    3. Iptables-l-N # or: Service iptables status

About MySQL Database remote access

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.