I was trying to change my phpmyadmin username and password in the sql query using the code below, but it deleted all of my databases and user accounts.
UPDATE mysql.user SET user='newusername',
password=PASSWORD('newpassword') WHERE user='root';
FLUSH PRIVILEGES;
What can I do to recover the possible best state of my system?
This query renames all
root
user tonewusername
, and sets their password toroot
. It doesn't change any other databases, neither deletes anything.Your databases should be still there.
ls /var/lib/mysql
can show, which dbs are really existing.The old passwords of the
root
user are gone, but a rough reversion of its username can be reached by anquery.
If you can't start your mysql server, stop the server, and temporarily restart it with
In this mode, the mysql entirely bypasses all authentication. More can you read from it here.