Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1984452
  • 博文数量: 176
  • 博客积分: 1857
  • 博客等级: 上尉
  • 技术积分: 2729
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-14 22:55
个人简介

吾生有涯,而知无涯,适当止学.循序渐进,步步提升 Talk is cheap, show me the code.

文章分类

全部博文(176)

文章存档

2019年(1)

2018年(14)

2017年(20)

2016年(31)

2015年(15)

2014年(5)

2013年(10)

2012年(80)

分类: Mysql/postgreSQL

2016-07-19 14:55:17

场景:
*.一直想不明白为啥my.cnf已经配置了如下配置:
[mysql@Nginx 3306]$ pwd
/opt/mysqldata/3306
[mysql@Nginx 3306]$ more my.cnf 
[client]
port = 3306
#socket = /opt/mysqldata/3306/mysql.sock
socket = /opt/mysqldata/3306/mysql.sock

但是执行如下命令:socket无法通过:
[mysql@Nginx ~]$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)


解决思路:
1.查看mysql的help命令有如下说明:
[mysql@Nginx 3306]$ mysql --help

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf 

说明,虽然mysqld调用的是你制定的mysql.cnf,但是mysql命令却只能调用/etc/my.cnf.因此
配置/etc/my.cnf,可以调用[client]中的socket选项,进去mysql。

[root@Nginx etc]# cp /etc/my.cnf.bak /etc/my.cnf

[mysql@Nginx ~]$ mysql -uroot -p'redhat'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.13-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

(root@localhost) [(none)]> 

阅读(1924) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~