连2002错误
shell> mysqldump -uroot -p123456 -d jact > jact.sql
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/usr/local/mysql/var/mysql.sock' (2) when trying to connect
意思是我们使用的连接mysql的unix套接字错误。
解决:
netstat -ln | grep mysql
输出:
unix 2 [ ACC ] STREAM LISTENING 7414 /var/lib/mysql/mysql.sock
mysqldump --socket=/var/lib/mysql/mysql.sock -uroot -p123456 -d jact > jact.sql
Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
原因:
同一个ip在短时间内产生太多(超过mysql数据库max_connection_errors的最大值)中断的数据库连接而导致的阻塞;
解决方法:
1、提高允许的max_connection_errors数量(治标不治本):
- 进入Mysql数据库查看max_connection_errors: show variables like '%max_connection_errors%';
- 修改max_connection_errors的数量为1000: set global max_connect_errors = 1000;
- 查看是否修改成功:show variables like '%max_connection_errors%';
2、使用mysqladmin flush-hosts 命令清理一下hosts文件(不知道mysqladmin在哪个目录下可以使用命令查找:whereis mysqladmin);
在查找到的目录下使用命令修改:/usr/bin/mysqladmin flush-hosts -h192.168.1.1 -P3308 -uroot -prootpwd;
备注:
其中端口号,用户名,密码都可以根据需要来添加和修改;
配置有master/slave主从数据库的要把主库和从库都修改一遍的(我就吃了这个亏明明很容易的几条命令结果折腾了大半天);
ERROR 2003 (HY000): Can't connect to MySQL server on "host" (111)
vim /etc/mysql/my.cnf
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1 <---注释掉这一行就可以远程登录了
MySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED]
没有初始化权限表导致
#cd /usr/local/mysql(进入mysql安装目录)
#chown -R mysql.mysql .
#su - mysql
$cd server
$scripts/mysql_install_db