mysql总是无法通过套接字socket连接数据库

qq_24044757 2016-10-19 08:04:41
my.cnf中mysqld的socket=/tmp/socket3306.sock
[client] 中socket=/tmp/socket3306.sock
[mysql]中socket=/tmp/socket3306.sock

但是mysql -uroot -p连接数据库必须使用-S指定socket的位置,不指定就报错:
error 2002:can't connect to local mysql server through socket '/tmp/mysql.sock'
看得出mysql还是在找/tmp/mysql.sock而不是/tmp/socket3306.sock
为什么my.cnf中mysql中的设置不起作用?
...全文
769 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
unique_name 2016-10-21
  • 打赏
  • 举报
回复
引用 2 楼 zhangsheng_1992 的回复:
额 格式出问题了 手写一遍吧 首先 which mysqld 查询处mysqld的目录 然后 /usr/local/mysql/bin/mysqld --verbose --help | grep -A 1 'Default options' 就可以查出来到底加载了哪个配置文件了
加载的配置文件是安装目录下的my.cnf,但配置文件中的mysql下的socket还是不起作用。
unique_name 2016-10-21
  • 打赏
  • 举报
回复
引用 3 楼 rucypli 的回复:
进数据库看看你设置的生效了没 show variables like '%socket%';
配置生效了,但mysql连接还是得加上—S
rucypli 2016-10-20
  • 打赏
  • 举报
回复
进数据库看看你设置的生效了没 show variables like '%socket%';
zhangsheng_1992 2016-10-20
  • 打赏
  • 举报
回复
额 格式出问题了 手写一遍吧 首先 which mysqld 查询处mysqld的目录 然后 /usr/local/mysql/bin/mysqld --verbose --help | grep -A 1 'Default options' 就可以查出来到底加载了哪个配置文件了
zhangsheng_1992 2016-10-20
  • 打赏
  • 举报
回复
你修改的my.conf可能不是mysqld默认加载的配置文件 使用下列命令查询mysqld加载的是哪个配置文件
[root@iZ25md9ryqxZ ~]# which mysqld
/usr/local/mysql/bin/mysqld
[root@iZ25md9ryqxZ ~]# /usr/local/mysql/bin/mysqld --verbose --help | grep -A 1 'Default options'
2016-10-20 10:23:13 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.30) starting as process 21019 ...
2016-10-20 10:23:14 21019 [Note] Plugin 'FEDERATED' is disabled.
Default options are read from the following files in the given order:
/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf 
2016-10-20 10:23:14 21019 [Note] Binlog end
2016-10-20 10:23:14 21019 [Note] Shutting down plugin 'MyISAM'
2016-10-20 10:23:14 21019 [Note] Shutting down plugin 'CSV'
希望能帮到你

56,679

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧