标签归档:mysql

mysql 无法启动,mysql日志已满,如何处理

1 mysql日志常规清理办法,
linux下手动清除mysql日志的方法
2 手动进入linux文件夹进入mysql目录删除日志信息

[root@localhost]cd /usr/mysql/var
iZ23ji6c7snZ.err iZ23ji6c7snZ.pid 数据库1 数据库2 mysql
mysql-bin.000015 mysql-bin.000016 mysql-bin.000017 mysql-bin.000018
mysql-bin.index
[root@localhost] rm -rf mysql-bin.000015
[root@localhost] rm -rf mysql-bin.000016
[root@localhost] rm -rf mysql-bin.000017
[root@localhost] rm -rf mysql-bin.000018

LINUX重启MYSQL方式

[root@localhost ~]service mysqld start //启动mysql

[root@localhost ~]/etc/inint.d/mysqld start //启动mysql

[root@localhost ~]service mysqld stop //停止mysql

[root@localhost ~]/etc/inint.d/mysqld stop //停止mysql

[root@localhost ~]service mysqld restart //重启mysql

[root@localhost ~]/etc/inint.d/mysqld restart //重启mysql

查看mysql是否启动

[root@localhost ~]/etc/init.d/mysqld status //查看mysql是否成功运行

mysql运行状态检测

[root@localhost ~]ps aux|grep mysqld //查看是否有mysqld进程运行
[root@localhost ~]ps -ef|grep mysqld //查看是否有mysqld进程运行

linux下手动清除mysql日志的方法


1.手动清除日志前 请检查mysql设置文件

[root@localhost ~]vi /etc/my.cnf
如果
#log-bin=mysql-bin

#binlog_format=mixed
被注释掉,那么此时我们手动删除mysql日志时,会提示

mysql> show master logs;

ERROR 1381 (HY000): You are not using binary logging

未启用mysql二进制日志

此时我们需要将#log-bin 和#binlog_format的”#”取消掉,如下图所示:
[root@localhost ~]vi /etc/my.cnf
取消mysql日志设置

2.重新启动mysql
[root@localhost ~]service mysqld restart; //重启mysql



3.进入mysql

3.1 查询mysql安装目录
[root@localhost ~]# ps -ef|grep mysql //查询 mysql的安装目录
root 28475 1 0 09:53 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe –datadir=/usr/local/mysql/var –pid-file=/usr/local/mysql/var/iZ23ji6c7snZ.pid
mysql 28572 28475 0 09:53 pts/0 00:00:00 /usr/local/mysql/libexec/mysqld –basedir=/usr/local/mysql –datadir=/usr/local/mysql/var –user=mysql –log-error=/usr/local/mysql/var/iZ23ji6c7snZ.err –pid-file=/usr/local/mysql/var/iZ23ji6c7snZ.pid –socket=/tmp/mysql.sock –port=3306
————————-

/usr/local/mysql/var mysql数据存放路径
/usr/local/mysql/bin mysql的运行路径

3.2 进入mysql 运行路径
[root@localhost ~]cd /usr/local/mysql/bin
[root@localhost bin]./mysql -u root -p
enterpassword:*******;
mysql>show master logs; //注意分号是mysql标识每条命令完毕的标志,所以必须在每条命令后面加入分号
如下所示:
show master logs;
+——————+———–+
| Log_name | File_size |
+——————+———–+
| mysql-bin.000015 | 1059063 |
| mysql-bin.000016 | 205828775 |
| mysql-bin.000017 | 106 |
+——————+———–+
3 rows in set (0.00 sec)
show_master_logs

删除日志文件
mysql>purge master logs to ‘mysql-bin.000017’; //删除mysql “mysql-bin.000017″之前的日志文件
Query OK, 0 rows affected (0.05 sec)
purge_master_logs_to


4.重启mysql

[root@localhost ~]service mysqld restart;//重启mysql