Sometimes the database machine is not the same machine as the project, then it involves the remote link database, the steps to configure the remote connection database are as follows:
1. View the information in the user table in MySQL database, for example, using use MySQL to switch to MySQL database, then using select Host, user from user lists all users and corresponding host addresses in the user table. Where host corresponds to the IP of the hosts allowed to access, "%" means that all IP is allowed to access the database, the user corresponds to the username, as shown in, the test user allows all IP to connect to this database, and the root user only allows access via local.
2, to give specific users a permission to the instructions
GRANT all privileges on * * to ' user_name ' @ ' host_name ';
FLUSH privileges;
The first instruction is to grant permission, and the second is to make the granted permission effective; the first instruction, *. * represents all the tables in all databases, and "Databasename.tablename" can be used to grant the appropriate object if the permissions for a particular table correspond to a particular database.
3, check the configuration file my.cnf, find bind_address This line, if this line is not commented out, and the corresponding address is the local address "127.0.0.1", then to comment out this sentence, or remote connection.
4, to the database users to change the password instructions
Update user set Password=password ("New password") where user= ' username ';
Settings for MySQL remote connection