时间:2023-02-22 09:37:11 | 栏目:Mysql | 点击:次
报错信息:
ERROR 2002: Can't connect to local MySQL server through socket ‘/tmp/mysql.sock' (111)
解决办法:
/usr/local/mysql/bin/mysqladmin -u root > -S /var/lib/mysql/mysql.sock password 'your.passwd'
或者做个软连接
ln -s /var/lib/mysql/mysql.sock /tmp
原因:
其实提示找不到 /tmp/mysql.sock有时也并不是/tmp目录下没这个文件,是启动命令不对。
/usr/local/mysql/bin/mysql -u root -p /usr/local/mysql/bin/mysqld --user=mysql& /usr/local/mysql/bin/mysqld --user=root& /usr/local/mysql/bin/mysqld_safe --user=root& /usr/local/mysql/bin/mysqld_safe --user=mysql& /usr/local/mysql/bin/safe_mysqld--uer=root&(注意safe_mysqld与mysqld_safe是不同的,&表示mysql在后台运行)
报错信息:
STOPPING server from pid file /usr/local/mysql/data/localhost.localdomain.pid 060304 11:46:21 mysqld ended
解决办法:
这是权限问题,我的mysql目录属于root用户,也属于root群组,改用mysqld_safe启动就没问题了,大家只要注意这几个mysql,safe_mysqld,mysqld_safe,mysqld,mysqladmin.多试几次,其实有时mysql已经正常启动了,查看mysql是否启动命令
ps -aux | grep mysqld
会看到如下类似内容
mysql 6394 0.0 1.5 10528 992 pts/3 S 16:16 0:00 /usr/local/mysql/mysql 6395 0.0 1.5 10528 992 pts/3 S 16:16 0:00 /usr/local/mysql/mysql 6396 0.0 1.5 10528 992 pts/3 S 16:16 0:00 /usr/local/mysql/root 6422 0.0 1.1 2408 732 pts/3 S 16:20 0:00 grep mysql
查看mysql是否在监听端口命令
netstat -tl | grep mysql
会看到如下类似内容
tcp 0 0 *:mysql *:* LISTEN
总结