error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' — Missing /var/run/mysqld/mysqld.sock

后端 未结 30 2152
日久生厌
日久生厌 2020-11-22 10:49

My problem started off with me not being able to log in as root any more on my mysql install. I was attempting to run mysql without passwords turned on... but whenever I

30条回答
  •  渐次进展
    2020-11-22 11:36

    I had similar problem on a CentOS VPS. If MySQL won't start or keeps crashing right after it starts, try these steps:

    1) Find my.cnf file (mine was located in /etc/my.cnf) and add the line:

    innodb_force_recovery = X

    replacing X with a number from 1 to 6, starting from 1 and then incrementing if MySQL won't start. Setting to 4, 5 or 6 can delete your data so be carefull and read http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html before.

    2) Restart MySQL service. Only SELECT will run and that's normal at this point.

    3) Dump all your databases/schemas with mysqldump one by one, do not compress the dumps because you'd have to uncompress them later anyway.

    4) Move (or delete!) only the bd's directories inside /var/lib/mysql, preserving the individual files in the root.

    5) Stop MySQL and then uncomment the line added in 1). Start MySQL.

    6) Recover all bd's dumped in 3).

    Good luck!

提交回复
热议问题