Linux错误汇总
一,Linux系统下安装完MySQL,启动MySQL报错:Neither host 'localhost.localdomain' nor 'localhost' could be looked up with...
[[email protected]ost ~]# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) [[email protected] ~]# /etc/rc.d/init.d/mysqld status mysqld 已停
或者是这样
[[email protected] ~]# service mysqld start 初始化 MySQL 数据库: Neither host 'localhost.localdomain' nor 'localhost' could be looked up with /usr/bin/resolveip Please configure the 'hostname' command to return a correct hostname. If you want to solve this at a later stage, restart this script with the --force option [失败]
解决方法:
1,编辑vi /etc/hosts文件
[[email protected] ~]# vi /etc/hosts #127.0.0.1 linuxtest.com 改为下面红色部分 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6
二、[[email protected] ~]# mysql #故障是没有那个命令
-bash: mysql: command not found
解决方法:
[[email protected] ~]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql [[email protected] ~]#echo 'export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile [[email protected] ~]#source /etc/profile
三、[[email protected] mysql]# service mysqld start
Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/promote.cache-dns.local.pid).
错误日志:161026 22:47:25 mysqld_safe mysqld from pid file /usr/local/mysql/data/promote.cache-dns.local.pid ended
解决方法:根据/etc/my.cnf 初始化数据即可。
[[email protected] mysql]# vi /etc/my.cnf 执行如下命令: [[email protected] mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysql.pid
1,可能是/usr/local/MySQL/data/rekfan.pid文件没有写的权限
解决方法:给予权限,执行 “chown -R mysql:mysql /var/data” “chmod -R 755 /usr/local/mysql/data” 然后重新启动mysqld!
2,可能进程里已经存在mysql进程
解决方法:用命令“ps -ef|grep mysqld”查看是否有mysqld进程,如果有使用“kill -9 进程号”杀死,然后重新启动mysqld!
3,可能是第二次在机器上安装mysql,有残余数据影响了服务的启动。
解决方法:去mysql的数据目录/data看看,如果存在mysql-bin.index,就赶快把它删除掉吧,它就是罪魁祸首了。本人就是使用第三条方法解决的 !
4,mysql在启动时没有指定配置文件时会使用/etc/my.cnf配置文件,请打开这个文件查看在[mysqld]节下有没有指定数据目录(datadir)。
解决方法:请在[mysqld]下设置这一行:datadir = /usr/local/mysql/data
5,skip-federated字段问题
解决方法:检查一下/etc/my.cnf文件中有没有没被注释掉的skip-federated字段,如果有就立即注释掉吧。
6,错误日志目录不存在
解决方法:使用“chown” “chmod”命令赋予mysql所有者及权限
7,selinux惹的祸,如果是centos系统,默认会开启selinux
解决方法:关闭它,打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX=disabled后存盘退出重启机器试试。
四,故障现象:ERROR 1045 (28000):Access denied for user 'root'@'localhost' (using password:NO)
解决方法:
[[email protected] ]#pkill mysqld [[email protected] ]#lsof -i :3306 [[email protected] ]#rm-rf /usr/local/mysql/data/* [[email protected] ]#cd /usr/local/mysql [[email protected] mysql ]#/scripts/mysql_install_db --basedir=/usr/locla/mysql --datadir=/usr/locla/mysql/data --user=mysql
五,zabbix网页出现连接数据库失败;mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
查看了错误日志: tail -fn 200 /var/log/mysqld.log 截取部分内容
InnoDB: Error: tried to read 65536 bytes at offset 0 3583488. InnoDB: Was only able to read 512. InnoDB: Fatal error: cannot read from file. OS error number 17.
解决方法:
进入cd /var/lib/mysql 删除了两个日志文件rm -rf ib_logfile0和rm -rf ib_logfile1 然后重启系统;然后/etc/init.d/mysqld start 启动成功。
原文地址:http://blog.51cto.com/hwg1227/2156211