Fli
06-23-2013, 05:28 PM
You will learn how to change and reset mysql password in Linux
Your mysql password can be: blank (empty, just hit Enter button) it can be also your default ssh login password, root, admin, test
if MySQL password is unknown, you can reset it easilly. Before reset, make sure if you are using any hosting control panel that you know how to change mysql root password in this control panel before doing reset. For resetting mysql root password, follow these steps:
How to reset
Stop mysql + start mysql in safe mode + Login to mysql without password
/etc/init.d/mysqld stop
mysqld_safe --skip-grant-tables
Then it will probably hang on message "mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql" (http://internetlifeforum.com/mysql-apache-php/2811-hanged-mysqld_safe-starting-mysqld-daemon-databases-var-lib-mysql/). So start new SSH session while keeping old one open.
In new SSH session execute:
mysql --user=root mysql
update user set Password=PASSWORD('YourNewMysqlPassword') where user='root'; flush privileges; exit;/etc/init.d/mysqld start
Source: http://instantcpanelhosting.com/knowledgebase/2/MySQL-password-how-to-reset-it.html
If this dont works, you can also create a php file as a root via command line (vi reset.php) and put this code in it: https://github.com/lxcenter/hypervm/blob/master/hypervm-install/reset-mysql-root-password.phps ; after that, run by command: php reset.php)
How to change password
mysqladmin -u root -p'oldpassword' password newpassword
then enter your present password and hit Enter key
Your mysql password can be: blank (empty, just hit Enter button) it can be also your default ssh login password, root, admin, test
if MySQL password is unknown, you can reset it easilly. Before reset, make sure if you are using any hosting control panel that you know how to change mysql root password in this control panel before doing reset. For resetting mysql root password, follow these steps:
How to reset
Stop mysql + start mysql in safe mode + Login to mysql without password
/etc/init.d/mysqld stop
mysqld_safe --skip-grant-tables
Then it will probably hang on message "mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql" (http://internetlifeforum.com/mysql-apache-php/2811-hanged-mysqld_safe-starting-mysqld-daemon-databases-var-lib-mysql/). So start new SSH session while keeping old one open.
In new SSH session execute:
mysql --user=root mysql
update user set Password=PASSWORD('YourNewMysqlPassword') where user='root'; flush privileges; exit;/etc/init.d/mysqld start
Source: http://instantcpanelhosting.com/knowledgebase/2/MySQL-password-how-to-reset-it.html
If this dont works, you can also create a php file as a root via command line (vi reset.php) and put this code in it: https://github.com/lxcenter/hypervm/blob/master/hypervm-install/reset-mysql-root-password.phps ; after that, run by command: php reset.php)
How to change password
mysqladmin -u root -p'oldpassword' password newpassword
then enter your present password and hit Enter key