In general, MySQL users do not have remote access permissions, so when the program and the database is not on the same server, we need to turn on MySQL remote access permissions. There are two methods to choose from: The Change of table method and the authorization method.
Change Table method:1, Login Mysqlmysql-u root-p
2. Modify the user table of the MySQL library and change the host entry from localhost to%. % here is to allow any host access, if only one IP access is allowed, you can change to the corresponding IP, For example, you can change localhost to 192.168.163.128, which means that only LAN 192.168.163.128 is allowed to access MySQL remotely. mysql> use MySQL; mysql> Update user Set host = '% ' where user = ' root '; Mysql> Select Host, user from user; mysql> flush Privileges;
Firewall open 3306 Port 1, open firewall configuration file Vi/etc/sysconfig/iptables
2. Add the following line-a input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT
:
3. Restart Firewall service iptables restart
Note: The added open 3306-port statement must be preceded by the icmp-host-prohibited
So far, most people have been able to link to their MySQL database remotely, but there may be problems. Remote connection database times wrong:
"1130-host ... is not allowed-to -connect to this MYSQL server"When you encounter this problem, I am afraid that you will continue to use the "authorization method" to the normal remote link database.
Authorization Law:Run on the machine where MySQL is installed: 1, mysql-h localhost-u root//This should allow access to MySQL server 2, mysql>grant all privileges on *. * to ' root ' @ '% ' with GRANT OPTION//give any host access to data Permissions 3, Mysql>flush privileges//Modify effective 4, Mysql>exit//exit MySQL server so that it can be on any other host Log in as Root!
For the authorization law, there are other uses: if you want to allow users to connect to the MySQL server myuser from IP 192.168.1.6, and use MyPassword as the password mysql>grant all privileges on * * to ' MyUser ' @ ' 192.168.1.6 ' identified by ' MyPassword ' with GRANT option;mysql>flush privileges;
If you want to allow users to connect to the MySQL server's DK database myuser from the IP 192.168.1.6 host, and use MyPassword as the password mysql>grant all privileges the dk.* to ' MyUser ' @ ' 192.168.1.6 ' identified by ' MyPassword ' with GRANT option;mysql>flush privileges;
After this big circle of toss, I think you should now in any case should be able to access your database remotely.
From for notes (Wiz)
MySQL server: Open MySQL remote connection