Create a root user in Mysql, and create a root user in mysql

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.