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.
- 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:
- Grant all privileges on *. * to 'root' @ '%' identified by '000000' with grant option;
- # 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)
- Flush privileges; # reload system Permissions
- Exit;
Allow port 3306
- Iptables-I INPUT-p tcp-m state -- state NEW-m tcp -- dport 3306-j ACCEPT
- # Check whether the rule takes effect
- Iptables-L-n # Or: service iptables status
- # The production environment is insecure at this time. After remote management, close the port and delete the previously added rules.
- 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