MySQL set up remote account login
2. ERROR 1045 (28000): Access denied for user 'test'@'x.x.x.x' (using password: NO) 1
3. Retrieve ROOT password and set remote login 2
4. RROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 2
5. ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'。 3
6. Set the user's remote host connection permission 4
7. Set permissions for users and libraries 4
---- Author Attilax , [email protected]
In order to set a remote connection permission for MYSQL users , it has gone through many twists and turns . It is hereby recorded . First, Yu arrived at the 2003 error
ERROR 2003 (HY00
The reason is that MySQL takes into account security factors, the default configuration only allows local login
Open the /etc/mysql/my.cnf file, find bind-address = 127.0.0.1 and change it to bind-address = 0.0.0.0
Restart mysql: sudo /etc/init.d/mysql restart
Connected again , error 1045 occurred
ERROR 1045 (28000): Access denied for user 'test'@'x.x.x.x' (using password: NO)
A: The reason is that the login user name is not set with the permission to log in to the remote host. There is also a possibility that you need to reset the password ... It may be that the authorized operation causes this sequelae ..
Log in locally as root : mysql -u root -p
Modify the Host field of the corresponding user name in the user table in the MySQL database , and change localhost to %
use mysql;
update user set Host = '%' where User = 'username';
Giving this setting permission requires the ROOT user to log in. Unfortunately , the ROOT password cannot be remembered .
Retrieve the ROOT password and set up remote login
mysqld_safe --skip-grant-tables &
mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
Set ROOT remote connection update user set host = '%' where user='root';
View the process , you can see the MYSQLD_SAFE and MYSQL processes , at this time MYSQL can be used normally , but check the parameters , you can see --skip-grant-tab
Enter the mysqld_safe command line, and immediately enter mysql -u root mysql without any mistakes . Or you can open a new window .
1062 error when doing UPDATE
RROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
If ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' error occurs when executing the update statement , it means that there are multiple ROOT users recorded in the USER table .
需要select host from user where user = 'root';
Check to see if the host already has the value of % , and that's it .
mysql> select host,user from user where user='root';
+-----------------------+------+
| host | user |
+-----------------------+------+
| % | root |
| 127.0.0.1 | root |
| ::1 | root |
| localhost.localdomain | root |
Then log in with the ROOT user to change the remote connection permissions of the user account . A prompt appears: ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql' .
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'。
It is because in the user table of the mysql database , there is an account with an empty user name, that is, an anonymous account. As a result, although root is used when logging in , it is actually logged in anonymously. You can log in through ''@'localhost' in the error prompt. See, so the solution see
First close the MYSQL process ..
Then
# mysqld_safe --skip-grant-table
The screen appears: Starting demo from .....
At this point, remember to enter
# mysql -u root mysql
mysql> delete from user where USER='';
mysql> FLUSH PRIVILEGES;
If there is Starting demo from .. after .. enter other commands first , then use mysql -u root mysql . It will show this error again .
Then KILL off the MYSQL process , .. restart the normal process ..
Set the user's remote host connection permission
update user set host = '%' where user='fanzkcom_fanzk';
FLUSH PRIVILEGES;
But in the actual connection, although it can be connected , it does not have the permission of the library where it is located , halo .
Just set the permissions next
Set permissions for users and libraries
grant all privileges on fanzkcom_fanzk.* to fanzkcom_fanzk@'%' identified by '1234';
FLUSH PRIVILEGES;
There must be single quotes around the percent sign , otherwise the syntax is wrong
Then when connecting, it even prompted 1045 error. Halo , after thinking about it for a long time , I still reset the password and try it .
update mysql.user set password=password('XXX') where User="fanzkcom_fanzk"
flush privileges;
It turned out to be good . Halo . I don't know why the password will be changed when setting authorization . Strange .. It should be a MYSQL bug