The error message suggests that your MySQL database is not running at all. You should check the logs, they surely contain something about why the database wasn't started. The easiest way of this is issuing the journalctl -x -u mysql
command right after service mysql start
.
If you still can't figure out what went wrong, backup all the directories from /var/lib/mysql/
, except the mysql/
and performance_schema/
directories.
After installing a new mysql server, stop it, and copy back the directories saved above. Be sure to maintain the correct file ownership.
If you're done, start the mysql server. You should see the databases with the root user, but not with anyone else. You can add a user who can access the database with the usual
GRANT ALL PRIVILEGES ON theDatabase.* to theUser identified by "thePassword";
command.
Also note that this is not the way to backup and restore a database. It probably works, but it might not. You should create a proper backup before something bad happens, i.e. just before you start using the database.