Problems with changing the root password of MySQL in Linux

Source: Internet
Author: User

For the process of changing the root password of MySQL in Linux, we can find a lot on the Internet, which is:

 

# Killall mysqld // interrupt the currently running MySQL process

# Mysqld_safe -- skip-grant-tables & // start the Security Mode

# MySQL // directly access MySQL without a password

--> Use MySQL // use a MySQL database instance

--> Update user SET Password = PASSWORD ('000000') where user = 'root ';

// Change the root user password to 123

Restart your computer and enter the following command:

Mysql-u root-P

123

You can access the MySQL database.

------------------------------------------------------------------------------

The above method was found on the internet, but when I started the security mode, I encountered a new problem:

Invalid 'mysql' user

Starting mysqld daemon with databases from/opt/MySQL/Data

Stopping server from PID file/opt/MySQL/data/localhost. localdomain. PID

There will be three lines of error information, searched for N on the Internet for a long time, and finally solved the problem. The solution is as follows:

For 'invalid user', my solution is:

# Groupadd MySQL

# Useradd-G MySQL

The next two lines are mainly about the permission of the data directory. When the database is started, a new file is generated to the directory, and the command is terminated because the permission is not allowed.

However, on different computers, the directory names are sometimes different and the following displays:

Starting mysqld daemon with databases from/opt/MySQL/var

Stopping server from PID file/opt/MySQL/var/localhost. localdomain. PID

Modify permission: chmod-r 1777 data/

Or chmod-r 1777 var/

Then, go through the password change process.

Note: The/opt/MySQL/data/localhost. localdomain. Err file is a MySQL error log file. If you cannot solve the problem, open this file to view the error log.

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.