December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Categories

December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

How to Recover a Mysql Root Password

Let’s  check how can we recover mysql root password if we lost it
Step # 1: Stop the MySQL server process.
Step # 2: Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for password.
Step # 3: Connect to mysql server as the root user.
Step # 4: Setup new mysql root account password.
Step # 5: Exit and restart the MySQL server.
Here are commands you need to type for each step (login as the root user)

 

# service mysqld stop
# mysqld_safe –skip-grant-tables &

[1] 13964
root@localhost ~]# Starting mysqld daemon with databases from /var/lib/mysql  ————nothing will show just type mysql
mysql —– typing mysql shows like this
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.0.77 Source distribution
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.
Or
ctrl z then

#mysql
mysql> use mysql;
mysql>update user set password=PASSWORD(“password@123#”) WHERE user=”root”;
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start

# mysql -u root -p  —— enter the database with new password

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>