Now a most common problem we are facing with the mysql on newly installed server if we have mysql 5 we mostly receive following error message when starting mysql service from WHM
“mysql has failed, please contact the sysadmin (result was “mysql has failed”).”
As well as when ever we run mysql from shell its gives error message
“Access denied for user ‘root’@’localhost’ (using password: YES)”.
In that case we need to remove mysql from server and reinstall it by using following commands.
1)Login into server as root user
root@Gunjan [~]# which mysql
/usr/bin/mysql
root@Gunjan [~]#mv /usr/bin/mysql /usr/bin/mysql-back
root@Gunjan [~]mv /var/lib/mysql /var/lib/mysql-back
root@Gunjan [~]/scripts/mysqlup –force
Now reset the root password from WHM >> Main >> SQL Services >> MySQL Root Password
Now you will able to access mysql without any problem 🙂
Some time above solution also not allowing to access mysql still throws following error message.
root@server[~]#mysql
“Access denied for user ‘root’@’localhost’
In that case refer following steps but carefully as it will cause you database loss.
root@server[~]#/etc/init.d/mysql stop
root@server[~]#mv /var/lib/mysql/ /var/lib/mysql-back
root@server[~]#mv /etc/my.cnf /etc/my.cnf-back
root@server[~]#/scripts/mysqlup –force
root@server[~]#/etc/init.d/mysql start
root@server[~]#mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1430564
Server version: 5.0.85-community MySQL Community Edition (GPL)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> \q
Bye
Now you can restore the databases from /var/lib/mysql-back to /var/lib/mysql