Do a website, to constantly update the database, contact the database must be MySQL. Sometimes when you build a station because the database and the site in different IP, this time need to use the program MySQL remote connection, and MySQL because of security factors, the default time users set is not remote connection, only local connection, this time will need to modify their settings. The following small series on the introduction of the Operation method.
Enter cmd command mode.
Mysql-h Localhost-u Mysql-p
Enter Password: Hu Jintao
Connect to the database.
mysql> use MySQL; (This DB stores various configuration information for MySQL)
Database changed
Mysql> select Host,user from user; (View user's permissions)
+-------------+-------+
| Host | user |
+-------------+-------+
| localhost | |
| localhost | Root |
| localhost | |
| localhost | MySQL |
+-------------+-------+
6 rows in Set (0.02 sec)
As you can see, you can only access it in localhost host mode.
Mysql> grant all privileges in *.* to ' root ' @ '% ' identified by ' password ' with Grant option;
(% means all external machines, if a particular machine is specified, change the% to the corresponding machine name; ') Root ' refers to the username to be used, where the password needs to be changed to the root password.
mysql> flush Privileges; (Run as sentence to take effect, or restart MySQL)
Query OK, 0 rows affected (0.03 sec)
Mysql> select Host,user from user; (View the user's permissions again)
+-------------+-------+
| Host | user |
+-------------+-------+
| % | MySQL |
| % | Root |
| localhost | |
| localhost | Root |
| localhost | |
| localhost | MySQL |
+-------------+-------+
Mysql>exit
Now try again: from the remote CMD side see can not log in, can log in, the general code can also be connected to the.
Small editing tips: Another need to note that the User Rights table is in the MySQL Database DB table, which detailed records of which users have permissions on which several databases have the right to operate, this is more important for multi-user management.