Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect 原创 2021-07-06 16:01 阅读(2657)次 想在mysql服务器中导出数据库,用来暂时备份用,执行以下语句: ./mysqldump -d db -u root -p >db.sql 却报如下错误: ``` mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect ``` 一般我们使用数据库都不会遇到这个问题,这估计是前人安装数据库时不负责,或者不按规范安装留下祸根,百度了下,最简单的解决办法是,找到当前mysql.sock的位置,修改/etc/my.cnf,增加如下配置: ``` [client] socket=/var/lib/mysql/mysql.sock ``` 重启数据就可以了 我贴一下我my.cnf完整的配置: ``` [mysql] socket=/var/lib/mysql/mysql.sock # set mysql client default chararter default-character-set=utf8 [mysqld] socket=/var/lib/mysql/mysql.sock # set mysql server port port = 3306 # set mysql install base dir basedir=/usr/local/mysql # set the data store dir datadir=/usr/local/mysql/data # set the number of allow max connnection max_connections=3000 # set server charactre default encoding character-set-server=utf8 # the storage engine default-storage-engine=INNODB lower_case_table_names=1 max_allowed_packet=16M explicit_defaults_for_timestamp=true # 取消密码验证 #skip-grant-tables # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # skip-grant-tables [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [mysql.server] user=mysql basedir=/usr/local/mysql [client] socket=/var/lib/mysql/mysql.sock ``` mysql 异常处理 上一篇:fastjson转字符串时保留null空字段 下一篇:json转List数组泛型如何转以及Map的泛型?
相关文章 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener(1195) Es 7.x版本批量写入数据路由字段报错:Action/metadata line [1] contains an unknown parameter [_routing](3590) solr搜索报错:Error from server at http://127.0.0.1:8983/solr/索引名: undefined field text(5187) Es创建索引mapping时报错:Root mapping definition has unsupported parameters: [doc(8447) 记一次maven报错解决:Failed to read artifact descriptor for com.aliyun.openservices:aliyun-openservices:jar:2.0.0-OTS(5641) elasticsearch7.1保存时报错: Validation Failed: 1: type is missing;(10515) windows nginx启动报错bind() to 0.0.0.0:80 failed (1949) feign报错java.lang.IllegalStateException: RequestParam.value() was empty on parameter 0(4010) feign报错:cannot retry due to redirection, in streaming mode(12282) seata并发测试报错:get global lock fail, xid:192.168.64.1:18091:2025291279, lockKeys:stock_info:1(7540) 推荐文章 elasticsearch7.1保存时报错: Validation Failed: 1: type is missing;(10515) 聊聊数据保存到MySQL后数据乱码的问题(1611) solr时区设置解决时间多8小时问题(2854) linux下MySQL5.7.18安装过程(1865) linux下MySQL5.6.2安装过程(1712) spring cloud+feign+mybatis中使用seata0.9实现分布式事务(6614) spring cloud gateway报错Only one connection receive subscriber allowed(4973) spring cloud中Feign调用诡异报错MethodNotAllowed: status 405 reading(8440) 使用spring4实现websocket连接(2683) jquery对象与dom对象互转(1509) 热门文章 clickhouse如何删除数据(39027) clickhouse清空删除表数据(17623) redis报错远程主机强迫关闭了一个现有的连接以及超时问题(15630) clickhouse执行查询内存超出限制问题:Memory limit (total) exceeded(13859) elasticsearch7.1保存时报错: Validation Failed: 1: type is missing;(10515) clickhouse如何修改字段名(9549) druid执行clickhouse报错:sql injection violation, dbType clickhouse , druid-version 1.2.2, syntax error(8568) Es创建索引mapping时报错:Root mapping definition has unsupported parameters: [doc(8446) Clickhouse批量删除分区(8075) postgresql生成uuid(7856) 标签列表 java java基础 微服务 异常处理 mysql spring boot spring cloud clickhouse elasticsearch linux feign jdbc js spring postgresql docker nginx seata gateway maven solr hsqldb canal dubbo 数据库 redis 大数据分析 分布式事务 架构 quartz rocketmq select2 win10 mybatis jenkins html springmvc hadoop git 消息队列 websocket xheditor 分布式 zookeeper 小程序 开发工具 数据库集群 电脑 笔记 设计模式 阿里云 activemq ajax bat eclipse freemarker gitlab hibernate http hystrix javamail jquery jvm redission redission对象 springmail svn ubuntu ueditor