Reputation: 2459
I cannot login to mysql since I forgot (I lost!) the temporary password I received after installing mysql. So I tried the following steps but they didn't help me:
/usr/local/mysql/support-files/
,called restore
, in which I wrote this line: SET PASSWORD FOR
root@localhost=PASSWORD('');
sudo mysqld_safe
--init-file=/usr/local/mysql/support-files/restore
but it stuck on mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
. However I checked mysql from system preference and it already started (showing "mysql is running")mysql -u root
, but still I receive the same error: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Could someone please help me fix this problem ?
Upvotes: 0
Views: 1296
Reputation: 2143
Try this
1. stop mysql server
2. sudo mysqld_safe --skip-grant-tables &
3. mysql -u root //it should not ask password
4. use mysql; //change to mysql db
5. update user set password=PASSWORD("secure password") where user='root';
or (depending on mysql version)
update user set authentication_string=password('secure password') where user='root';
6. flush privileges;
7. logout from mysql (quit)
8. start mysql server (mysql -u root -p)
Upvotes: 1