Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql : changing root password

Tags:

mysql

I mistakenly keyed in

<delete from mysql.user where password =''>

Unfortunately the password for user is ''.

When I try to use mysqladmin i am getting message that I cannot set password for

<root @ localhost>

Any ideas???

Many thanks

like image 667
Naomi Hurley Avatar asked Dec 03 '25 16:12

Naomi Hurley


1 Answers

If you are using a Unix-like OS:

  1. You have to kill the mysql daemon.
  2. Create a text file and write:
UPDATE mysql.user SET Password=PASSWORD('YOUR_PASSWORD') WHERE User='root';

FLUSH PRIVILEGES;

  1. Open a console and type "mysqld_safe --init-file=YOUR_FILE &"
  2. Restart the server
  3. Now you should be able to work.
like image 105
amusero Avatar answered Dec 06 '25 07:12

amusero



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!