MySQL5.5系がservice mysqld startで起動しない
症状
こちらの記事を参考に、無事MySQL5.5系をインストールすることが出来ました。
しかし、いざ起動させようとすると、FAILDとなります。
[root@localhost mysql]# service mysqld start MySQL Daemon failed to start. Starting mysqld: [FAILED]
エラーログを見てみます。
[root@localhost mysql]# cat /var/log/mysqld.log 170302 4:23:25 [Note] Plugin 'FEDERATED' is disabled. 170302 4:23:25 InnoDB: The InnoDB memory heap is disabled 170302 4:23:25 InnoDB: Mutexes and rw_locks use GCC atomic builtins 170302 4:23:25 InnoDB: Compressed tables use zlib 1.2.3 170302 4:23:25 InnoDB: Using Linux native AIO 170302 4:23:25 InnoDB: Initializing buffer pool, size = 128.0M 170302 4:23:25 InnoDB: Completed initialization of buffer pool InnoDB: Error: checksum mismatch in data file ./ibdata1 170302 4:23:25 InnoDB: Could not open or create data files. 170302 4:23:25 InnoDB: If you tried to add new data files, and it failed here, 170302 4:23:25 InnoDB: you should now edit innodb_data_file_path in my.cnf back 170302 4:23:25 InnoDB: to what it was, and remove the new ibdata files InnoDB created 170302 4:23:25 InnoDB: in this failed attempt. InnoDB only wrote those files full of 170302 4:23:25 InnoDB: zeros, but did not yet use them in any way. But be careful: do not 170302 4:23:25 InnoDB: remove old data files which contain your precious data! 170302 4:23:25 [ERROR] Plugin 'InnoDB' init function returned error. 170302 4:23:25 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 170302 4:23:25 [ERROR] Unknown/unsupported storage engine: InnoDB 170302 4:23:25 [ERROR] Aborting 170302 4:23:25 [Note] /usr/sbin/mysqld: Shutdown complete
解決手順
いろいろ、記事を探してみると、バージョンアップ前から作成されている元々あったMySQLデータを一度別の場所に退避して、起動してみると良いらしい。
MySQLのデータのパスは設定ファイルの/etc/my.cnf
に記載されています。
[root@localhost mysql]# vi /etc/my.cnf [mysqld] datadir=/var/lib/mysql
この場合だと/var/lib/mysql
です。恐らくデフォルトで、/var/lib/mysql
だと思います。
このディレクトリに何が置いてあるか、というと。
[root@localhost /]# cd /var/lib/mysql/ [root@localhost mysql]# ls auto.cnf ibdata1 ib_logfile1_tes hoge_development test ib_buffer_pool ib_logfile0_tes mysql hoge_test
なんか色々入ってます。このMySQLはRailsで使用しているので、hoge_development
、hoge_test
などの既存DBが置いてあるがわかります。
このすべてをどこかにバックアップ(退避)しつつ、
[root@localhost mysql]# ls
空の状態を確認して、再度MySQLを起動してみましょう。
[root@localhost mysql]# service mysqld start Initializing MySQL database: 170302 4:25:09 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. 170302 4:25:09 [Note] /usr/sbin/mysqld (mysqld 5.5.54) starting as process 15584 ... 170302 4:25:09 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. 170302 4:25:09 [Note] /usr/sbin/mysqld (mysqld 5.5.54) starting as process 15591 ... PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. Please report any problems at http://bugs.mysql.com/ [ OK ] Starting mysqld: [ OK ]
起動できたっぽいです。 入れるかな。。。
[root@localhost mysql]# mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.5.54 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
入れました! あとはdumpしたデータベースを復元して、完了です。