记一次mysql server 错误

由于一些错误操作导致mysql server 无法正常启动

tail /var/log/mysqld.log

查看错误日志:

1
2
3
4
5
6
7
8
9
10
11
12
ERROR 1286 (42000): Unknown table engine 'InnoDB'

InnoDB: stored checksum 1820380758, prior-to-4.0.14-form stored checksum 1820380758
InnoDB: Page lsn 2 3436109869, low 4 bytes of lsn at page end 3436109869
InnoDB: Page number (if stored to page already) 5,
InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 0
InnoDB: Page may be a transaction system page
InnoDB: Also the page in the doublewrite buffer is corrupt.
InnoDB: Cannot continue operation.
InnoDB: You can try to recover the database with the my.cnf
InnoDB: option:
InnoDB: innodb\_force\_recovery=6

修改/etc/my.cnf innodb_force_recovery=6 后重启mysql。 备份所有数据库:

mysqldump -A -uroot -p > all.sql

由于mysql server很久没升级了,而且用的是阿里云提供的安装脚本,我想完全删除再通过yum安装: 删除mysql客户端及服务端

yum remove mysql mysql-server

移除或备份mysql数据文件夹

mv /var/lib/mysql /var/lib/mysql\_old\_backup

安装mysql社区版

yum instanll mysql mysql-server

启动mysql-server

sudo /sbin/service mysqld start

报错:

[ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable

解决:

chown -R mysql:mysql /var/lib/mysql

初始安装设置 查看安装后的默认root密码

sudo grep 'temporary password' /var/log/mysqld.log

下面会提示输入上面查到的密码

sudo /usr/bin/mysql_secure_installation

查看运行的django网站日志

……
MySQLdb ……
……
OperationalError: (2002, “Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)”)

MySQLdb尝试通过 ‘/tmp/mysql.sock’连接mysql 而此时mysql通过 ‘/var/lib/mysql/mysql.sock’建立的连接,调整django settings

DATABASES = {
    'default': {
       ......
        'OPTIONS': { 'unix_socket':'/var/lib/mysql/mysql.sock'}
    }
}

在此期间发现另一个错误

OperationalError: (1193, "Unknown system variable 'storage_engine'")

这是之前在DATABASES OPTIONS里配置的,可能由于mysql版本差异(新安装的是5.7.20 MySQL Community Server)已经没有这个变量了,于是删除了这块的配置。

"init_command": "SET storage_engine=INNODB"

以上所有操作都在CentOS release 6.5 (Final)进行的。

面向前端开发人员的rails教程 flexiable.js 研究
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×