Reputation: 35
I executed the following command to change the DB password:
mysql> UPDATE mysql.user SET Password=('root') WHERE User = 'root';
Query OK, 4 rows affected (0.06 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
Now I can not access the DB using the password 'root'. I get the following message:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Can anyone help me with this?
Upvotes: 0
Views: 70
Reputation:
On your Terminal
, please, run this:
Stop MySQL daemon:
/etc/init.d/mysql stop
Start safely MySQL:
sudo /usr/bin/mysqld_safe --skip-grant-tables &
Then you can start resetting your password:
SET PASSWORD FOR 'root@localhost' = PASSWORD('yourNewPassword');
FLUSH PRIVILEGES;
EDIT:
I run the commands step by step on my own computer. You can follow them, they run successfully:
begueradj@begueradj-X71Q:/var/www$ sudo /etc/init.d/mysql stop
[sudo] password for begueradj:
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql stop
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop mysql
mysql stop/waiting
begueradj@begueradj-X71Q:/var/www$ sudo mysqld_safe --skip-grant-tables &
[2] 6035
begueradj@begueradj-X71Q:/var/www$ 141023 10:11:43 mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
141023 10:11:43 mysqld_safe Logging to '/var/log/mysql/error.log'.
141023 10:11:43 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
begueradj@begueradj-X71Q:/var/www$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.37-0ubuntu0.12.04.1 (Ubuntu)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
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("begueradj") where User='root';
Query OK, 4 rows affected (0.02 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
You can exit now. BEGUERADJ.
Upvotes: 1