Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38)

后端 未结 30 2702
再見小時候
再見小時候 2020-11-22 04:23

I am having a big problem trying to connect to mysql. When I run:

/usr/local/mysql/bin/mysql start

I have the following error :

<         


        
30条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 04:30

    I had this problem too when trying to start the server, so many of the answers here that just say to start the server didn't work. The first thing you can do is execute the following to see if there are any config errors:

    /usr/sbin/mysqld --verbose --help 1>/dev/null
    

    I did have one error that showed up:

    160816 19:24:33 [Note] /usr/sbin/mysqld (mysqld 5.5.50-0ubuntu0.14.04.1-log) starting as process 9461 ...
    160816 19:24:33 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
    160816 19:24:33 [Note] Plugin 'FEDERATED' is disabled.
    160816 19:24:33 [ERROR] /usr/sbin/mysqld: unknown variable 'innodb-online-alter-log-max-size=4294967296'
    160816 19:24:33 [ERROR] Aborting
    

    A simple grep -HR "innodb-online-alter-log-max-size" /etc/mysql/ showed me exactly what file contained the offending line, so I removed that line from the file.

    Then, checking my /var/log/mysql/error.log file I had:

    InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
    InnoDB: than specified in the .cnf file 0 671088640 bytes!
    160816 22:46:46 [ERROR] Plugin 'InnoDB' init function returned error.
    160816 22:46:46 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
    160816 22:46:46 [ERROR] Unknown/unsupported storage engine: InnoDB
    160816 22:46:46 [ERROR] Aborting
    

    Based on this question the accepted solution wouldn't work because I couldn't even get the server started, so I followed what some of the comments said and deleted my /var/lib/mysql/ib_logfile0 and /var/lib/mysql/ib_logfile1 files.

    This allowed the server to start and I was able to connect and execute queries, however checking my error log file it was quickly getting filled up with several tens of thousands of lines like this:

    160816 22:52:15  InnoDB: Error: page 1415 log sequence number 82039318708
    InnoDB: is in the future! Current system log sequence number 81640793100.
    InnoDB: Your database may be corrupt or you may have copied the InnoDB
    InnoDB: tablespace but not the InnoDB log files. See
    InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
    InnoDB: for more information.
    

    Based on a suggestion from here, to fix this I did a mysqldump and restore of all databases (see the link for several other solutions).

    $ mysqldump -u root -p --allow-keywords --add-drop-database --comments --hex-blob --opt --quote-names --databases db_1 db_2 db_3 db_etc > backup-all-databases.sql
    $ mysql -u root -p < backup-all-databases.sql
    

    Everything appears to be working as expected now.

提交回复
热议问题