Create a root user in Mysql, and create a root user in mysql
After mysql is installed in linux, an error occurs. At first I thought there was no password problem. I modified it according to this article: after the first login to mysql in linux, I should be correct, however, the root login of the service cannot be started again. The following describes the problems and solutions:
mysqld_safe--skip-grant-tables&mysql-uroot mysql mysql> select * from user; Empty set (0.00 sec) mysql> select USER(); +--------+ | USER()| +--------+ | root@ | +--------+ 1 row in set (0.00 sec)
|
I was surprised to find that there was no root user. The user table was empty, but this was the first time I encountered this problem.
Because
In mysqld_safe -- skip-grant-tables, grant is not allowed. Therefore, the following error occurs:
** For your convenience, here are some instructions: the first value is host, and the second value is user. password ("my_password") is required, MY_PASSWORD is the password, while 'y' has 28, followed by 1 enum and 3 blob can be empty, that is, 4 null characters here, and 4 for the int type, the default value is 0.
INSERTINTO user VALUES('%','root',password('MY_PASSWORD'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0)
|
Here, we need to use password ('Password') for the password of the 3rd fields, because the password in mysql is encoded and not saved as a direct string.
Then, after killing all mysql processes and restarting mysql normally, you can log on as the root user.