找回密码
 注册
查看: 617|回复: 0

ERROR 2002 (HY000): Can't connect to local MySQL server through socket mysql报错解

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2022-9-22 11:55:32 | 显示全部楼层 |阅读模式
[root@ceph1 /]# mysql -uroot -p ' E2 K' ]' y2 Q/ Q' R4 ~
Enter password:
. W  x9 G' i( P$ `7 B: ~3 x4 R$ NERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
7 l7 X. c. Z# n! }* k* Z0 I1 T[root@ceph1 /]# , O. p3 {" u. p  O/ J8 H
[root@ceph1 /]#
8 R( a! y- m: [- K[root@ceph1 /]# 1 I& n( G! u9 Y0 t* v! }7 A
添加个client的配置
$ _# j+ J) Z" `# V+ t% Y' |' z[root@ceph1 /]# vim /etc/my.cnf
. N* I& z2 W( O- G$ |3 \) w7 m0 h4 f
[client]
- k& e; S4 {$ M0 k# J1 lport=3306: j/ s0 ~+ {' ?2 V: {# H0 y
socket=/var/lib/mysql/mysql.sock
, t6 l& I" m7 t( H
7 r, \1 A& Q3 ?9 L, m- i4 ?[root@ceph1 /]# service mysqld restart
8 ^! `4 E0 p0 F6 jShutting down MySQL.. SUCCESS!
* N3 {8 v# E' s3 u3 J+ y! DStarting MySQL.. SUCCESS! 5 W  p, `" z5 G% \
[root@ceph1 /]# mysql -uroot -p 3 U7 @+ G7 V' e
Enter password:
7 F- F. H; z% @  |4 UWelcome to the MySQL monitor.  Commands end with ; or \g.- j: i. E  e7 ^
Your MySQL connection id is 16 _/ c! Q3 F! a; W
Server version: 5.6.20 Source distribution
+ L: ?, ^0 r. w/ B
$ c+ U4 v7 j4 J6 W! a2 N  r6 dCopyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
4 z9 H3 {6 G# l2 H' y
. G2 G1 [/ k! [; hOracle is a registered trademark of Oracle Corporation and/or its
, J0 O: B1 k  Qaffiliates. Other names may be trademarks of their respective. a$ ~0 g5 f0 n# [, w6 [
owners.
  f/ \+ d6 R$ h* L2 o' X/ g& H; a* n& y) R
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.# c; p9 K: ?3 c6 @

3 B2 d" r9 U" L# G* m8 Kmysql> 0 W: E/ o# x, E
mysql>
  N3 Q, k+ W* N$ m! f- N4 S) n, q( P( ?# X, @7 L" e
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 01:22 , Processed in 0.015257 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表