Change the root password of MySQL under CentOS

Source: Internet
Author: User
Tags mysql command line

After MySQL installation, MySQL command line login MySQL prompt following error:

Access denied for user ' root ' @ ' localhost ' (using Password:yes)

The possible reason is that you do not know the root password caused.

You can modify the root user password using the following methods:

1. Modify the service startup parameters

sudo vi/usr/lib/systemd/system/mysqld.service

Start command plus skip-grant-tables parameter

Execstart=/usr/bin/mysqld_safe--skip-grant-tables

2, the implementation of Daemon-reload

sudo systemctl daemon-reload

3. Restart MySQL Service

sudo systemctl restart mysqld

4. Log in to MySQL using the root user

Mysql-uroot

5. Change the root password

Use MySQL;

Update user set Password=password ("123456") where user= ' root ';

6. Refresh Permissions

Refresh permissions when password is modified

Flush privileges;

7. Remove the skip-grant-tables of the service startup parameters and restart

The start command is modified to:

Execstart=/usr/bin/mysqld_safe

After the modification, the execution

sudo systemctl daemon-reload

sudo systemctl restart mysqld

After rebooting, you can log in using root/123456.

Change the root password of MySQL under CentOS

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.