当前位置: 技术问答>linux和unix
求助:linux mysql多实例,2002 (HY000): Can't connect to local MySQL server
来源: 互联网 发布时间:2016-12-28
本文导语: 我在 /etc/my.cnf 已经配置了 sock文件,可是它依然提示 :Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 可是,明明我的配的不是mysql.sock文件呀。 my.cnf 配置如下: 23# mysql more instance 24 [mysql...
我在 /etc/my.cnf 已经配置了 sock文件,可是它依然提示 :Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 可是,明明我的配的不是mysql.sock文件呀。
my.cnf 配置如下:
求高人, 如果指定sock是可以登录的 (mysql -u root -P 3308 -S /tmp/mysql_queue.sock -p)
不指定的话就提示(mysql -u root -P 3308 -p):ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
my.cnf 配置如下:
23# mysql more instance
24 [mysqld_multi]
25 mysqld=/usr/local/mysql/bin/mysqld_safe
26 mysqladmin=/usr/local/mysql/bin/mysqladmin
27 user=root
28
29
30 # Here follows entries for some specific programs
31
32 # The first MySQL server
33 [mysqld1]
34 socket = /tmp/mysql1.sock
35 port = 3307
36 pid-file = /tmp/mysql1.pid
datadir=/data/mysql
51 user=mysql
57 #
58 #skip-networking
59
62 log-bin=mysql-bin
63
64 # binary logging format - mixed recommended
65 binlog_format=mixed
[mysqld2]
144 socket = /tmp/mysql_queue.sock
145 port = 3308
146 pid-file = /tmp/mysql_queue.pid
159
160 datadir=/data/mysql_queue
161 log=/data/mysql_queue/mysql_queue.log
183 [mysqldump]
184 quick
185 max_allowed_packet = 16M
186
187 [mysql]
188 no-auto-rehash
189 # Remove the next comment character if you are not familiar with SQL
190 #safe-updates
191
192 [myisamchk]
193 key_buffer_size = 128M
194 sort_buffer_size = 128M
195 read_buffer = 2M
196 write_buffer = 2M
197
198 [mysqlhotcopy]
199 interactive-timeout
求高人, 如果指定sock是可以登录的 (mysql -u root -P 3308 -S /tmp/mysql_queue.sock -p)
不指定的话就提示(mysql -u root -P 3308 -p):ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
|
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
这里提示你默认去找到的是'/tmp/mysql.sock' (2),而不试lz指定的mysql_queue.sock
这里提示你默认去找到的是'/tmp/mysql.sock' (2),而不试lz指定的mysql_queue.sock
|
1、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.
另外看看是不是权限问题.
2、确定你的mysql.sock是不是在那个位置,
mysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock
3、试试:service mysqld start
4、如果是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql
[root@localhost ~]# /etc/init.d/mysqld start
启动 MySQL: [ 确定 ]
[root@localhost ~]# mysql -uroot -p
另外看看是不是权限问题.
2、确定你的mysql.sock是不是在那个位置,
mysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock
3、试试:service mysqld start
4、如果是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql
[root@localhost ~]# /etc/init.d/mysqld start
启动 MySQL: [ 确定 ]
[root@localhost ~]# mysql -uroot -p