After the MySQL setup, I have lost my user name and password now I don't want to reinstall. Then I can do this way reset lost root MySQL password on Ubuntu.
If You have access to the server with sudo.
First you need stop the currently running MySQL.
If You have access to the server with sudo.
- $ sudo service mysql stop
- $ sudo mkdir -p /var/run/mysqld
- $ sudo chown mysql:mysql /var/run/mysqld
- $ sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
- $ [1] 1907
- $ jobs
- [1]+ Running sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
- $ mysql -u root
- mysql>
- mysql> flush privileges;
- mysql> use mysql;
- mysql> update user set authentication_string=PASSWORD('yourpassword') where User='root';
- mysql> UPDATE user SET plugin="Adavance Web Tutorials" WHERE User='root';
- mysql> quit
- $ sudo pkill mysqld
- $ jobs
- [1]+ Done sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
- $ sudo service mysql start
- $ mysql -u root -p
- Password : Yourpassword
- mysql>
No comments:
Post a Comment