Mysql: change root password
4 answers
If you are using a Unix-like OS:
- You need to kill the mysql daemon.
- Create a text file and write:
UPDATE mysql.user SET Password=PASSWORD('YOUR_PASSWORD') WHERE User='root';
FLUSH PRIVILEGES;
- Open a console and enter "mysqld_safe --init-file = YOUR_FILE &"
- Reboot the server
- You should now be able to work.
+1
source to share
Stop mysqld
and restart it using a parameter --skip-grant-tables
. Then run in mysql shell:
INSERT INTO user
VALUES('localhost','user',PASSWORD('newpass'),
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
'','','','',0,0,0,0);
Logout and restart mysql normally.
0
source to share