Greetings!
To access MySQL db from terminal it is necessary to give its root password
Since i forgot its root password, i ended up with the following error
Error:
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’
(using password: NO)
Then i followed the below steps to reset it
Steps:
1. [root@venus ~]# service mysqld stop
Stopping mysqld: [ OK ]
2. [root@venus ~]# mysqld_safe –skip-grant-tables & [1] 3735
3. [root@venus ~]# 110809 10:43:22 mysqld_safe Logging to ‘/var/log/mysqld.log’. 110809 10:43:22 mysqld_safe
Starting mysqld daemon with databases from /var/lib/mysql
4. [root@venus ~]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.56 Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to modify and redistribute it under the GPL v2 license
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
5. mysql> UPDATE user SET password=PASSWORD(“slash123″)WHERE user=”root”;
ERROR 1046 (3D000): No database selected
( Note: Here “slash123” is my mysql root password )
6. mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| django |
| drupal |
| mysql |
| student |
| test |
+——————–+
6 rows in set (0.34 sec)
7. 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
8. mysql> UPDATE user SET password=PASSWORD(“slash123″)WHERE user=”root”;
Query OK, 3 rows affected (1.07 sec) Rows matched: 3 Changed: 3 Warnings: 0
9. mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
10. mysql> quit Bye
11. [rajee@venus ~]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.56 Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
That’s it 🙂
Now i am able to access MySQL prompt from the terminal
[…] : https://sraji.wordpress.com/2011/08/10/how-to-reset-mysql-root-password/ Tagged as: access, error, greetings, mysql, password, terminal Leave a comment Comments (0) […]
Thank you – this helped me!
Thanks a lot! This article really helped me!