Today needs to test the system function locally, because there is no database, you need to connect the remote database in the program;
SSH login to the remote server, with the root of the database to see the situation;
Mysql> SelectHost,User, Password fromMysql.User;+----------------+------------------+-------------------------------------------+|Host| User |Password|+----------------+------------------+-------------------------------------------+|localhost|Root| *836e233974ebe6ea32f95f890a91363f8427f78b||Iz94926clkiz|Root| *836e233974ebe6ea32f95f890a91363f8427f78b|| 127.0.0.1 |Root| *836e233974ebe6ea32f95f890a91363f8427f78b||::1 |Root| *836e233974ebe6ea32f95f890a91363f8427f78b||localhost|Debian-Sys-Maint| *1460ed3535abdbb887f9e5f57f40a2354610cdf3|+----------------+------------------+-------------------------------------------+5Rowsinch Set(0.00Sec
A total of 5 MySQL accounts, the host column can be seen, these accounts are only support server native connection, now we create a remote user;
Create User by ' 123456 ';
+----------------+------------------+-------------------------------------------+|Host| User |Password|+----------------+------------------+-------------------------------------------+|localhost|Root| *836e283974ebe6ea32f95f890a91363f8427f78b||Iz949s6clkiz|Root| *836e283974ebe6ea32f95f890a91363f8427f78b|| 127.0.0.1 |Root| *836e283974ebe6ea32f95f890a91363f8427f78b||::1 |Root| *836e283974ebe6ea32f95f890a91363f8427f78b||localhost|Debian-Sys-Maint| *1460ed35e5abdbb887f9e5f57f40a2354610cdf3|| % |Test| *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9|+----------------+------------------+-------------------------------------------+6Rowsinch Set(0.00Sec
Create completed, in the program inside the connection found or no permissions, just now we just created the user, has not assigned permission to this user;
Grant All Privileges on *. * to ' Test '@'%'by'123456'with Grantoption;
All means to accept all actions, such as select,insert,delete ...; *. * represents all tables below all libraries;% is allowed to log in from anywhere; for security periods, this percentage can be replaced with the IP address you allow;
Then refresh the MySQL user Rights related table;
privileges ;
I thought it was done, and so on, the program is still not even up, or access deny;
The port is not 3306, open the MySQL configuration file, is the default of 3306, and then looked down, found a key place;
Bind-address =127.0. 0.1
Here MySQL default binding local IP, do not accept other sources; Comment out, restart MySQL all OK;
There are also two common operations;
Modify the specified user password
update MySQL. User set Password=password (' new password 'whereUser= and Host="localhost";
Delete User
Delete from User where User = ' Test ' and Host='localhost';
MySQL creates a remote user and authorizes