admin/ December 7, 2016/ Linux/ 0 comments

On Unix, use the following procedure to reset the password for the MySQL ‘root’@’localhost’ account. To change the password for a root account with a different host name part, modify the instructions to use that host name.

The instructions assume that you will start the MySQL server from the Unix login account that you normally use for running it. For example, if you run the server using the mysql login account, you should log in as mysql before using the instructions. Alternatively, you can log in as root, but in this case you must start mysqld with the –user=mysql option. If you start the server as root without using –user=mysql, the server may create root-owned files in the data directory, such as log files, and these may cause permission-related problems for future server startups. If that happens, you will need to either change the ownership of the files to mysql or remove them.

Log on to your system as the Unix user that the MySQL server runs as (for example, mysql).

Step1: Stop the mysql service

(Ubuntu and Debian) Run the following command:

(CentOS, Fedora, and Red Hat Enterprise Linux) Run the following command:

Step2: Start MySQL without a password
Run the following command. The ampersand (&) at the end of the command is required.

Step3: Connect to MySQL

Step4: Set a new MySQL root password

Step5: Flush Privileges

Share this Post

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.