1./cd
/Usr/local/mysql/bin
./Mysql-h localhost-u root
// You can access the MySQL server.
2. mysql> GRANT ALL
Privileges on *. * TO 'root' @ '%' WITH GRANT OPTION
// Grant data access permissions to any host
For example, if you want myuser to use mypassword to connect to the mysql server from any host.
GRANT
All privileges on *. * TO 'myuser' @ '%' identified by 'mypassword' WI
TH www.2cto.com
Grant option;
If you want to allow myuser to connect to the mysql server from a host whose ip address is 192.168.1.6, and use mypassword as the password
GRANT
All privileges on *. * TO 'myuser' @ '192. 168.1.3 'IDENTIFIED
'Mypassword'
With grant option;
3. mysql> FLUSH
PRIVILEGES
// The modification takes effect.
Mysql> EXIT
4. Modify iptables to open the Mysql port to allow remote access
Modify the firewall configuration file: vi
/Etc/sysconfig/iptables Add the following line:-A RH-Firewall-1-INPUT-m state
-State NEW-m tcp-p tcp-dport 3306-j ACCEPT
If you want to activate ports such as 21, you only need to replace 3306 with the ports to be opened, such as 21. After configuration, restart iptable service
Iptables restart can access Mysql from other machines. Note:-A RH-Firewall-1-INPUT-m
State-state NEW-m tcp-p tcp-dport 3306-j ACCEPT-
RH-Firewall-1-INPUT-j REJECT-reject-with icmp-host-prohibited-
RH-Firewall-1-INPUT-j REJECT-reject-with icmp-host-prohibited
It indicates that icmp access is denied. If other packets are returned, a host cannot be accessed. The 3306 error is returned.
The port line must be before icmp-host-prohibited.