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

后端 未结 30 2176
再見小時候
再見小時候 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:37

    For me - this was simply a case of MySQL taking a long time to load. I have over 100,000 tables in one of my databases and it did eventually start but obviously has to take a long time in this instance.

    0 讨论(0)
  • 2020-11-22 04:37

    Adding

    --protocol=tcp 
    

    to the list of pramaters in your connection worked for me.

    0 讨论(0)
  • 2020-11-22 04:38

    are you sure you installed mysql as well as mysql server..

    For example to install mySql server I'll use yum or apt to install both mysql command line tool and the server:

    yum -y install mysql mysql-server (or apt-get install mysql mysql-server)
    

    Enable the MySQL service:

    /sbin/chkconfig mysqld on
    

    Start the MySQL server:

    /sbin/service mysqld start
    

    afterwards set the MySQL root password:

    mysqladmin -u root password 'new-password' (with the quotes)
    

    I hope it helps.

    0 讨论(0)
  • 2020-11-22 04:38

    I ran into this issue today. None of these answers provided the fix. I needed to do the following commands (found here https://stackoverflow.com/a/20141146/633107) for my mysql service to start:

    sudo /etc/init.d/mysql stop
    cd /var/lib/mysql/
    ls ib_logfile*
    mv ib_logfile0 ib_logfile0.bak
    mv ib_logfile1 ib_logfile1.bak
    ... etc ...
    /etc/init.d/mysql restart
    

    This was partly indicated by the following errors in /var/log/mysql/error.log:

    140319 11:58:21 InnoDB: Completed initialization of buffer pool
    InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
    InnoDB: than specified in the .cnf file 0 5242880 bytes!
    140319 11:58:21 [ERROR] Plugin 'InnoDB' init function returned error.
    140319 11:58:21 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
    140319 11:58:21 [ERROR] Unknown/unsupported storage engine: InnoDB
    140319 11:58:21 [ERROR] Aborting
    

    I also saw the disk full error, but only when running commands without sudo. If the permissions check fails, it reports disk full (even when your partition is not even close to full).

    0 讨论(0)
  • 2020-11-22 04:41

    To prevent the problem from occurring, you must perform a graceful shutdown of the server from the command line rather than powering off the server.

    shutdown -h now
    

    This will stop the running services before powering down the machine.

    Based on Centos, an additional method for getting it back up again when you run into this problem is to move mysql.sock:

    mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak
    
    service mysqld start
    

    Restarting the service creates a new entry called mqsql.sock

    0 讨论(0)
  • 2020-11-22 04:41

    Another workaround is to edit /etc/my.cnf and include host in the section [client]

     [client]
     #password       = your_password
     host            = 127.0.0.1
     port            = 3306
     socket          = /var/run/mysql/mysql.sock
    

    And then restarting the mysql service.

    This workaround was tested in: Server version: 5.5.25a-log Source distribution

    0 讨论(0)
提交回复
热议问题