Cant access root @localhost in MYSQL

February 23, 2015 3.8k views

Logged into phpmyadmin and changed a password there and then ever since was unable to get beyond the phpmyadmin welcome page and getting error 1045, even though inputting the password just chosen. Since there was no data on the site yet, as the site was being prepared for a wordpress database migration from a locally hosted site, the decision was made to deinstall and then possibly reinstall phpmyadmin, when this was attempted, during the deinstallation was asked for a mysql root password, the process was denied in part and the same error 1045 showed up at the command line.
Now how would one override or reconfigure the mysql root user so as to be able to reinstall phpmydmin and gain the necessary user privileges to administer the site in the future. Suggestions would be greatly appreciated.

  • Have you attempted to access the root account either via phpmyadmin or via the mysql command line tool using the original password instead of your new one (in case it was accidentally changed for root@someotherhost rather than root@localhost)

    The password you are working with is the MySQL password and not the phpmyadmin one (phpmyadmin simply inherits it) so to get back to a clean state you would need to completely remove and re-install MySQL or restore the root password using this procedure.

    If you have nothing in your database you need to save this may be quicker:

    apt-get purge mysql-server
    apt-get install mysql-server

    You will likely then need to re-install php5-mysql (if you're using it) and phpmyadmin as they depend on MySQL and would have been removed when you removed MySQL.

  • After the access denial message received on the the non-root user's account--which is the account that had its password modified, tried to access the root account through both phpmyadmin and through the command line (by using the " mysql -u root -p" ) when asked for password, access was denied error 1045.
    Was initially curious to know if there was a work-around to having to deinstall mysql and reinstall all over again, but if this what has to be done then whatever.

    Also, is phpmyadmin constantly locking out users who modify passwords? just wondering...Ok. thanks

  • Wow, still cannot access the mysql root user. I've uninstalled and reinstalled the mysql server several times over.
    If I run

    mysql -u root -p

    I get the prompt to enter password even though I have not yet configured any password into the newly reinstalled mysql. If I type something in or if I don't, I still get this error regardless:
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2).

Be the first one to answer this question.