my.cnf 问题小计--ERROR 2002

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: 场景: *.一直想不明白为啥my.cnf已经配置了如下配置: [mysql@Nginx 3306]$ pwd /opt/mysqldata/3306 [mysql@Nginx 3306]$ more my.
场景:
*.一直想不明白为啥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)]> 

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
10天前
|
关系型数据库 MySQL 数据库
MySQL为什么存在的表显示doesn‘t exist?
MySQL为什么存在的表显示doesn‘t exist?
18 0
|
17天前
|
缓存 关系型数据库 MySQL
mysql5.7 mysql配置文件my.cnf 中 query_cache_min_res_unit 的优化
mysql5.7 mysql配置文件my.cnf 中 query_cache_min_res_unit 的优化
6 0
|
4月前
|
关系型数据库 MySQL 数据库
Mysql-错误处理: Found option without preceding group in config file
Mysql-错误处理: Found option without preceding group in config file
150 0
|
10月前
|
SQL 关系型数据库 MySQL
修改mysql的密码时遇到问题ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corre
修改mysql的密码时遇到问题ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corre
|
11月前
|
关系型数据库 MySQL
|
存储 关系型数据库 MySQL
MySQL出现Data too long for column...(错误号1406)和 Data truncated for column...(错误号1265)
MySQL出现Data too long for column...(错误号1406)和 Data truncated for column...(错误号1265)
583 0
MySQL出现Data too long for column...(错误号1406)和 Data truncated for column...(错误号1265)
|
关系型数据库 MySQL 数据库
mysql插入表时报错ERROR 1067 (42000): Invalid default value for ‘end_time‘
mysql插入表时报错ERROR 1067 (42000): Invalid default value for ‘end_time‘
|
SQL 关系型数据库 MySQL
MySQL - [ERR] 1064 - You have an error in your SQL syntax check the manual……
MySQL - [ERR] 1064 - You have an error in your SQL syntax check the manual……
185 0
|
SQL 关系型数据库 MySQL
Mysql报错: ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregate
Mysql报错: ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregate
185 0
|
开发工具 容器
解决报错:Couldn't create temporary file /tmp/apt.conf.IRqbCz
问题 操作容器应该是属于服务器开发同学的常规操作,经常我们会遇到系统缺少对应的工具的情况,比如我们进入容器后,想使用 vim 修改某个文件,但是发现该容器没有安装 vim 工具。这个时候,一般都需要自己手动安装,比如在 unbuntu 系统中,可以使用 apt-get 包管理命令。
602 0
解决报错:Couldn't create temporary file /tmp/apt.conf.IRqbCz