First please try using
mysql -u root -p
and enter your password (if you remember) at the prompt to login as the sql-root user (note the switch
-p is for password).
If you really have to reset your root password for mysql, here's an easy way - reconfigure the package with
dpkg-reconfigure.Easy steps to reset mySQL root password:
- Check the version of your
mysql-server;apt-cache policy mysql-serverand see for the line which shows the installed version among other information. e.g. for my install it's:Installed: 5.5.37-0ubuntu0.12.04.1(From this I know that I havemysql-server-5.5installed in my system.) - Start the reconfiguration with:
sudo dpkg-reconfigure mysql-server-*.*where mysql-server-*.* should be replaced by the version that you have. (for me it'd be mysql-server-5.5). This will stop the database daemon. A prompt will then appear where you'd have to enter your new password and confirm the reconfiguration.The daemon will be automatically started after the reconfig completes. - You can then log in with:
mysql -u root -pand start your database admin tasks.
References:
- https://help.ubuntu.com/community/MysqlPasswordReset [Which would soon be cleaned up as indicated in the page.]
- Ubuntu Server Guide related to your specific version, available at: https://help.ubuntu.com/. Select your Ubuntu version and click on Ubuntu Server Guide and look for the database help page.
No comments:
Post a Comment