Enable remote access to centos mysql, centosmysql

Source: Internet
Author: User

Enable remote access to centos mysql, centosmysql

Log on to MySQL: mysql-u root-p db;

To change the password, use mysqladmin-u root password NEWPASSWORD for the first time.

Set: mysqladmin-u root-p 'oldpassword' password newpassword

Run the following command to enable remote access restriction grant all privileges on *. * to 'root' @ '192. 168.0.1 'identified by 'Password' with grant option;

Flush privileges;

Exit;

The IP address 192.168.0.1 is enabled. To enable all IP addresses, replace the IP address with %.

Grant all privileges on *. * to 'root' @ '%' identified by 'Password' with grant option;

 

 

 

CentOS, the following commands should also be OK in debian and other systems.

  1. Mysql-u root-p mysql # 1st mysql is the execution command, and 2nd mysql is the system data name

Run the following command on the mysql console:

  1. Grant all privileges on *. * to 'root' @ '%' identified by '000000' with grant option;
  2. # The root Account is the user name, and % represents any host. The logon password specified by '123456' (this password can be set different from the local root password without affecting each other)
  3. Flush privileges; # reload system Permissions
  4. Exit;

Allow port 3306

  1. Iptables-I INPUT-p tcp-m state -- state NEW-m tcp -- dport 3306-j ACCEPT
  2. # Check whether the rule takes effect
  3. Iptables-L-n # Or: service iptables status
  4. # The production environment is insecure at this time. After remote management, close the port and delete the previously added rules.
  5. Iptables-d input-p tcp-m state -- state NEW-m tcp -- dport 3306-j ACCEPT

PS. The above iptables addition/deletion rules are temporary. If the rules take effect after restart, save the modification: service iptables save # Or:/etc/init. d/iptables save In addition, vi/etc/sysconfig/iptables # The following rule can also be added-a input-p tcp-m state -- state NEW-m tcp -- dport 3306-j ACCEPT

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.