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:

  1. I stopped mysql server
  2. 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('');
  3. 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")
  4. 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 ?

Answers


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)

Need Your Help

Remove gap between two rectangles in CSS

jquery css css3

I created a menu item with jquery and CSS but is has a gap in menu items..One item is placed on top op other ite..I want to remove this gap and push every eliment right litle by litle as I shown in...

Are there specifications for simplified subsets of XML?

xml xml-parsing subset specifications microxml

When I first heard about the W3C-backed MicroXML, I thought of an idea I read somewhere years ago: a simpler subset of the XML specification without attributes (and without namespaces IIRC). The th...