Ubuntu: Mysql root password when install from Ubuntu Software Center [duplicate]


This question already has an answer here:

I install MySql Server and MySql Client on my Ubuntu 16.04.1 from "Ubuntu Software Center".

As far as I know, when you install mysql-server from terminal, it prompt for root password in the middle of installation process. But when I install it from "Ubuntu Software Center", it just installed and I don't know what the root password is.


Here is how to stop/kill the existing mysql daemon, in case it is running:

 sudo  ps -ef | grep mysql      - checks if mysql/mysqld is one of the running processes.     sudo kill -9 'pid' mysqld             - kills the daemon, if it is running.  

Run MySQL safe daemon with skipping grant tables

 sudo mysqld_safe --skip-grant-tables &  

Login to MySQL as root with no password

 sudo mysql -u root mysql  

Run UPDATE query to reset the root password

  UPDATE user SET authentication_string=PASSWORD("MyNewPassword") WHERE user="root";    FLUSH PRIVILEGES;  

Stop MySQL safe daemon

 sudo  ps -ef | grep mysqld_safe    sudo kill -9 'pid' mysqld_safe  

Start MySQL daemon

sudo /etc/init.d/mysql start  

Privileges are flushed. Start MySQL and login as root with the password you reseted

 sudo mysql -u root -p mysql  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »