There are a lot of solutions for this on the Internet, and I have adopted
Written in more detail such as:
1. Change the table method. It may be that your account is not allowed to log on remotely, only on localhost. This time, as long as the computer on the localhost, log in to MySQL, change the "MySQL" Database in the "User" table "host", from "localhost" to "%"
Code:mysql-u root-p123
Mysql>use MySQL;
Mysql>update User Set host = '% ' where user = ' root ';
Mysql>select host, user from user;
2. Authorization law. For example, if you want Kevin to use MyPassword to connect to a MySQL server from any host.
Code:grant all privileges on * * to ' kevin ' @ '% ' identified by ' MyPassword ' with GRANT OPTION;
If you want to allow the user Kevin to connect to the MySQL server from the IP-192.168.101.234 host and use MyPassword as the password
Code:grant all privileges on * * to ' kevin ' @ ' 192.168.101.234 ' identified by ' MyPassword ' with GRANT OPTION;
3. If it does not work as above (usually like under Windows) then modify the following configuration file (I am in the Linux environment you can find their own MySQL installation directory of the corresponding configuration file)
Code:vi/etc/mysql/my.cnf
Comment out
CODE: #bind-address = 127.0.0.1
Done!!!
Then I used the first method, and then I ran out of the last sentence after a mistake error 1062 (23000): Duplicate entry '%-root ' for key ' PRIMARY '
Then went to find a solution, found that the first
Mysql> Select host from user where user = ' root ';
+ ——————— –+
| Host |
+ ——————— –+
| % |
| 127.0.0.1 |
| Localhost.localdomain |
+ ——————— –+
3 Rows in Set (0.00 sec)
The host already has the% value, so run the command directly:
Mysql>flush privileges;
Sure enough, due to MySQL is not very deep understanding, through PHP really can be remote access, but I ignored a little
After the host = '% ', it can be accessed remotely, but we cannot access the local by using root
This is because% means that all except this machine is allowed to access
If you have already done so, then you will be visiting locally
#mysql-U root-p
When you enter a password, you are prompted
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)
This is very depressed, the machine has been unable to log in, then we need safe mode to enter (personal understanding for Safe mode)
First, stop the MySQL service
#/etc/init.d/mysql stop or #sudo service mysqld stop
And then execute
# mysqld_safe–user=mysql–skip-grant-tables–skip-networking &
Remember that & in the back is needed.
After some hints should be in the starting ... After
Enter MySQL directly to enter the database (in fact, this can also be forgotten password after the method of changing the password)
After entering, the statement to change the password is:
mysql> use MySQL;
Enter database Change Password
mysql> Update user Set password = password (' Your new password ') where user= ' root '
If it is to solve the above modification of the host method is to execute
mysql> Update user set host= ' localhost ' where user= ' root ' and host= '% '
Change the host back
But is it not possible to change back to remote access?
In fact, we can add a user, the necessary permissions granted to this user, and the user's host set to%
The errors that occur during the process are carefully reviewed, and the state of the firewall may affect the remote connection of the database.
MySQL cannot access the solution remotely