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/

 

上一篇:Linux一些最基础操作


下一篇:docker 中使用vlc