找回密码
 注册
查看: 616|回复: 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
( q: ~8 \* x2 i0 }Enter password:
* Z$ v* U+ h4 u, NERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
7 @. `2 L7 b8 @+ L, t6 E[root@ceph1 /]#
0 k' N, S  R, ?# U' r5 ^% e+ j[root@ceph1 /]# ; s" q' v) Y0 ~
[root@ceph1 /]#
& q$ }! ?' }3 V添加个client的配置
$ n+ Q* W6 E; k! N8 Z# ^5 c0 k[root@ceph1 /]# vim /etc/my.cnf
0 a, {7 i# ~2 G' C& j2 r; ]+ ~( ^) s/ e- k) `( }
[client]
" g5 n7 U- ]0 ?9 ~5 b" Wport=3306
# g- W/ o' u$ n- M0 Msocket=/var/lib/mysql/mysql.sock: l( O1 M" Y: J/ h

  H. ~7 Z% N: P' F: B  I[root@ceph1 /]# service mysqld restart
, p, @2 ^' r, K8 UShutting down MySQL.. SUCCESS!
- G+ V2 [2 R/ j7 I5 A+ k0 jStarting MySQL.. SUCCESS! + f( {9 e. \( x6 a* `
[root@ceph1 /]# mysql -uroot -p 4 V1 c: q2 m8 [* r# ^( S2 e* \
Enter password:
7 ]# W+ d& o! r4 G2 rWelcome to the MySQL monitor.  Commands end with ; or \g.
$ O' j$ i' M+ D; VYour MySQL connection id is 1
9 }! b6 k3 w6 e' I) F7 O: AServer version: 5.6.20 Source distribution
* D' v# w+ C7 U, L' M2 I  M: y% h' q, C7 c: u' i
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.( R& ]  ]& u' [+ b' X" c

$ `0 C! T1 r8 Y8 kOracle is a registered trademark of Oracle Corporation and/or its
3 d' b. o) S1 ?/ @3 u' |5 Haffiliates. Other names may be trademarks of their respective
9 M) i, B0 |. N& d' z  j2 M+ b, ]owners./ o; M: E2 q4 e/ z5 G( I7 I$ _* ^

0 \! X( F6 f" E" h$ eType 'help;' or '\h' for help. Type '\c' to clear the current input statement.  L( `# [9 i: y. `+ t( U. ~* W7 C( P9 D5 B

2 V: w0 y2 x- tmysql>
4 q3 {- W# U# n4 U0 u! a+ _mysql> ! k9 N2 l$ \$ g( g1 A1 ?6 E

' x2 }  C9 }6 j+ j$ L6 f# I! X# N
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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