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

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

    CentOS 7, 64 bit. Fresh installation.
    In my case, the error was because I didn't have the right MySQL server and MySQL client installed.
    Using yum, I removed mariadb and mysql-community edition. I downloaded the rpm's for the client and server from the official MySQL website and installed the server and client.

    On installing the server, I was shown a message that the password to the root account for MySQL was stored in a file which I could view with sudo cat /root/.mysql_secret.

    So after installing the client and server, I checked if MySQL was working (I think I rebooted before doing so) with the command sudo service mysql status and I got the result.

    MySQL running (2601) [ OK ]

    I logged into MySQL using the password from the .mysql_secret file:
    mysql -uroot -pdxM01Xfg3DXEPabpf. Note that dxM01Xfg3DXEPabpf is the password mentioned in the .mysql_secret file.

    and then typed entered the following command at the mysql prompt to change the password of root:

    mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('somePassword');

    Everything worked fine from then on.

提交回复
热议问题