forget the temporary mysql passowrd
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:
- I stopped mysql server
- Then I created a file in /usr/local/mysql/support-files/,called restore, in which I wrote this line: SET PASSWORD FOR root@localhost=PASSWORD('');
- Finally I ran this command: 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")
- I tried to login to mysql again with this command 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 ?
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)