无法通过连接到本地mysql服务器,无法通过套接字'/var/lib/mysql/mysql.sock'连接到本地MySQL服务器(2)...

I just manually installed a new plugin on my WordPress site, created a table in MySQL for the plugin's entries, and when I try to open the page that uses the plugin, I receive this error:

DataTables warning (table id = 'to-do_list'): An error occurred while

connecting to the database 'wordpress_clouse'. The error reported by the

server was: SQLSTATE[HY000] [2002] Can't connect to local MySQL server

through socket '/var/lib/mysql/mysql.sock' (2)

This is the MySQL info listed in my config file (which I believe is correct):

"type" => "Mysql",

"user" => "root",

"pass" => "******",

"host" => "localhost",

"port" => "",

"db" => "******"

This is the main contents of the /etc/my.cnf file:

# The following options will be passed to all MySQL clients

[client]

#port = 3306

socket = /var/run/mysqld/mysqld.sock

# The MySQL server

[mysqld]

#port = 3306

socket = /var/run/mysqld/mysqld.sock

log_error = mysqld.err

skip-networking

I've looked at answers to similar errors but none of the solutions worked for me. Any help would be appreciated.

解决方案

Here's what helped me solve this problem, which was that the actual file directory on my server was /var/lib/mysql/mysql.sock, not /var/lib/mysqld/mysqld.sock:

Open your my.cnf file

Add the following to your [client] section (if you don't have a [client] section, then add it). It should look like this:

[client]

socket=/var/lib/mysql/mysql.sock

The error should be gone. Many thanks to @alvits for pointing me in the right direction.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值