ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/my

2022/1/28 19:05:00

本文主要是介绍ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/my,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

最近换环境,docker安装mysql8时报错,解决方案如下

找到 my.cnf进行修改

# 添加一下数据
[client]
# 默认字符集
#default-character-set=utf8
socket= /var/run/mysqld/mysqld.sock 

[mysql]
# 默认字符集
#default-character-set=utf8
socket= /var/run/mysqld/mysqld.sock     ####这里 对应报错 这里原来的配置在上面[client]写一份
#socket= /storage/db/mysql/mysql.sock
[mysqld]
#
server-id=01
port=3306
## 开启二进制日志功能
log-bin=mysql-slave-bin
## relay_log配置中继日志
relay_log=edu-mysql-relay-bin
# 忽略大小写
lower_case_table_names=1

pid-file= /var/run/mysqld/mysqld.pid

socket= /var/run/mysqld/mysqld.sock
#socket= /storage/db/mysql/mysql.sock
# 数据库数据存放目录
datadir= /var/lib/mysql

secure-file-priv= NULL

# Disabling symbolic-links is recommended to prevent assorted security risks
skip-symbolic-links=0
# 最大链接数
max_connections=200
# 最大失败次数
max_connect_errors=10
# 默认时区
default-time_zone='+8:00'

character-set-client-handshake=FALSE

character_set_server=utf8mb4

# default-character-set=utf8

collation-server=utf8mb4_unicode_ci

init_connect='SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci'

# 默认使用‘mysql_native_password’插件认证
default_authentication_plugin= mysql_native_password

# Custom config should go here
!includedir /etc/mysql/conf.d/

 



这篇关于ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/my的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程