MySQL
Reset forgotten MySQL root password
Submitted by ravisagar on Tue, 01/08/2008 - 04:08.If you have forgotten your MySQL root password then don't worry. You can reset your lost password. Here is the procedure.
1. Login as root.
2. Kill running MySQL process and stop the MySQL service.
[root@localhost root]# killall mysqld
[root@localhost root]# /usr/libexec/mysqld -Sg --user=root &
3. Restart MySQL server with these parameters
[root@localhost root]# mysqld --skip-grant-tables --user=root
4. Manually set root password in the table "user" of "mysql" database.
[root@localhost root]# mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1 to server version: 3.23.41
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql> USE mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> UPDATE user
-> SET password=password("newpassword")
-> WHERE user="root";
Query OK, 2 rows affected (0.04 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> exit;
[root@localhosthost root]# killall mysqld
5. Restart MySQL again
[root@localhosthost root]# /etc/init.d/mysqld start
Now your root password is set and you can now login as root using the password you have just created.
[root@localhost root]# mysql -u root -p
Enter Password: "newpassword"
If you again forget your root password don't worry just check this link again :)
- ravisagar's blog
- 1 comment
- 671 reads
How to configure MySQL
Submitted by ravisagar on Thu, 01/03/2008 - 04:24.By default the root password for MySQL is blank, but it is not safe.
Set the root password by entering the following in terminal.
mysqladmin -u root -p password 'password'
This will set the root password.
Now you can login to the MySQL using the password you have just created.
mysql -u root -p
This will ask you for the root password, just enter the password to access the MySQL console.
- ravisagar's blog
- 1 comment
- 465 reads

Recent comments
4 weeks 5 days ago
7 weeks 6 days ago
8 weeks 3 days ago
8 weeks 3 days ago
20 weeks 4 days ago
20 weeks 4 days ago
21 weeks 3 days ago
25 weeks 6 days ago