Anansewaa
mysql 5.7 and linux server

Reset root password via command line interface – mysql 5.7 and linux server

The MySQL root password allows the root user to have full access to the MySQL database. You must have (Linux) root administrator access to the server to reset the MySQL root password.
Use the following steps to reset a MySQL root password by using the command line interface.

Stop The MySQL Service

(Ubuntu And Debian) Run the following command:

sudo /etc/init.d/mysql stop

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

sudo /etc/init.d/mysqld stop

Start MySQL Without A Password

Run the following command. The ampersand (&) at the end of the command is required.

sudo mysqld_safe --skip-grant-tables &

Connect To MySQL

Run the following command:

mysql -uroot

Set A New MySQL Root Password

Run the following command:

use mysql;
update user set authentication_string=PASSWORD("mynewpassword") where user='root';
flush privileges;
quit

Stop And Start The MySQL Service

 

(Ubuntu And Debian) Run the following commands:

sudo /etc/init.d/mysql stop
...
sudo /etc/init.d/mysql start

(CentOS, Fedora, And Red Hat Enterprise Linux) Run the following commands:

sudo /etc/init.d/mysqld stop
...
sudo /etc/init.d/mysqld start

Log In To The Database

Test the new password by logging in to the database.

mysql -u root -p

You are prompted for your new password.

Allan Barku

People are often unreasonable and self-centered. Forgive them anyway. If you are kind, people may accuse you of ulterior motives. Be kind anyway. If you are honest, people may cheat you. Be honest anyway. If you find happiness, people may be jealous. Be happy anyway.

Add comment

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most discussed

%d bloggers like this: