MISC

Ubuntu16.04 - mysql-serverのインストールエラー

Setting up mysql-server-5.7 (5.7.16-0ubuntu0.16.04.1) … Renaming removed key_buffer and myisam-recover options (if present)

わけわからなくなってる。わけわからないのでapt-get remove mysql-serverとしてもエラーでるし、そうかと思ったらrootのパスワードが消えて、mysqlとやっただけで、mysqlに入れるようになってエラーもでなくなった。そうかと思えば、今度はapt-get upgradeしたら、またmysql関連のエラーがでる、というか上記を表示したまま10分くらい動かない。最初にmysql-serverをインストールしたときも実は同じ状況で、上記の行が表示されたまま動かないので強制終了したら、mysqlが入ってた、でも起動しようと思ったらエラーになった。

さて、やっと動きました。

apt-get upgrade

Reading package lists… Done Building dependency tree Reading state information… Done Calculating upgrade… Done The following packages were automatically installed and are no longer required: liblockfile-bin liblockfile1 libsigsegv2 m4 sendmail-base sendmail-cf sensible-mda Use ‘sudo apt autoremove’ to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 1 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] y Setting up mysql-server-5.7 (5.7.16-0ubuntu0.16.04.1) … Renaming removed key_buffer and myisam-recover options (if present) dpkg: error processing package mysql-server-5.7 (—configure): subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: mysql-server-5.7 E: Sub-process /usr/bin/dpkg returned an error code (1)

とりあえずエラーになるからあきらめきれずに、apt-getコマンド使うと毎回mysqlをごにょごにょするようになっていることはわかった。Renaming removed kye_buffer and myisam-recover options(if present)というのは何をやっているのか?とりあえず、mysqlのログを見てみる。

Check that you do not already have another mysqld process using the same InnoDB data or log files.

さっきも同じエラーだったんだけどなー。今、mysqlとうつと、ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)となる。ps -aux |grep mysqlとして出てくるプロセスを全部killしてみて、もう一度mysqlとしても同じエラー。

ログ見たら下記が増えてる。 2016-11-07T16:51:13.482439Z 0 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data! 2016-11-07T16:51:13.482462Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Cannot open a file 2016-11-07T16:51:14.083816Z 0 [ERROR] Plugin ‘InnoDB’ init function returned error. 2016-11-07T16:51:14.083897Z 0 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 2016-11-07T16:51:14.083910Z 0 [ERROR] Failed to initialize plugins. 2016-11-07T16:51:14.083916Z 0 [ERROR] Aborting

2016-11-07T16:51:14.083926Z 0 [Note] Binlog end 2016-11-07T16:51:14.084070Z 0 [Note] Shutting down plugin ‘CSV’ 2016-11-07T16:51:14.084086Z 0 [Note] Shutting down plugin ‘MyISAM’ 2016-11-07T16:51:14.084822Z 0 [Note] mysqld: Shutdown complete

何か他のやつをapt-get installしようとすると、下記のエラーでる E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable) E: Unable to lock directory /var/cache/apt/archives/

http://www.ilovex.co.jp/blog/system/projectandsystemdevelopment/mycnfinnodbmysql.html

ここに、ibなんとかというファイルを消す必要があると書いてあるのでやってみた。 あと、上記の/var/cache/apt/archives/lockも削除した。 もう一度apt-get upgradeやってみる。

なんかちょっと進展している。でも止まる。動かない。

Setting up mysql-server-5.7 (5.7.16-0ubuntu0.16.04.1) … Renaming removed key_buffer and myisam-recover options (if present) Checking if update is needed. This installation of MySQL is already upgraded to 5.7.16, use —force if you still need to run mysql_upgrade

今度はここから動かない。もうやだ。

apt purge mysql-server mysql-server-5.7 mysql-server-core-5.7

Reading package lists… Done Building dependency tree Reading state information… Done Package ‘mysql-server’ is not installed, so not removed The following packages will be REMOVED: mysql-server-5.7 mysql-server-core-5.7 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded. 1 not fully installed or removed. After this operation, 94.3 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database … 130246 files and directories currently installed.) Removing mysql-server-5.7 (5.7.16-0ubuntu0.16.04.1) … update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode Purging configuration files for mysql-server-5.7 (5.7.16-0ubuntu0.16.04.1) … Removing mysql-server-core-5.7 (5.7.16-0ubuntu0.16.04.1) … Processing triggers for man-db (2.7.5-1) …

dpkg -l | grep mysql

ii dbconfig-mysql 2.0.4ubuntu1 all dbconfig-common MySQL/MariaDB support ii mysql-client-5.7 5.7.16-0ubuntu0.16.04.1 amd64 MySQL database client binaries ii mysql-client-core-5.7 5.7.16-0ubuntu0.16.04.1 amd64 MySQL database core client binaries ii mysql-common 5.7.16-0ubuntu0.16.04.1 all MySQL database common files, e.g. /etc/mysql/my.cnf ii php-mysql 1:7.0+35ubuntu6 all MySQL module for PHP [default] ii php7.0-mysql 7.0.8-0ubuntu0.16.04.3 amd64 MySQL module for PHP

apt install mysql-server

Reading package lists… Done Building dependency tree Reading state information… Done The following additional packages will be installed: mysql-server-5.7 mysql-server-core-5.7 Suggested packages: mailx tinyca The following NEW packages will be installed: mysql-server mysql-server-5.7 mysql-server-core-5.7 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/10.0 MB of archives. After this operation, 94.5 MB of additional disk space will be used. Do you want to continue? [Y/n] y Preconfiguring packages … Selecting previously unselected package mysql-server-core-5.7. (Reading database … 130065 files and directories currently installed.) Preparing to unpack …/mysql-server-core-5.7_5.7.16-0ubuntu0.16.04.1_amd64.deb … Unpacking mysql-server-core-5.7 (5.7.16-0ubuntu0.16.04.1) … Selecting previously unselected package mysql-server-5.7. Preparing to unpack …/mysql-server-5.7_5.7.16-0ubuntu0.16.04.1_amd64.deb … Unpacking mysql-server-5.7 (5.7.16-0ubuntu0.16.04.1) … Selecting previously unselected package mysql-server. Preparing to unpack …/mysql-server_5.7.16-0ubuntu0.16.04.1_all.deb … Unpacking mysql-server (5.7.16-0ubuntu0.16.04.1) … Processing triggers for man-db (2.7.5-1) … Processing triggers for ureadahead (0.100.0-19) … Processing triggers for systemd (229-4ubuntu12) … Setting up mysql-server-core-5.7 (5.7.16-0ubuntu0.16.04.1) … Setting up mysql-server-5.7 (5.7.16-0ubuntu0.16.04.1) … update-alternatives: warning: alternative /etc/mysql/my.cnf.fallback (part of link group my.cnf) doesn’t exist; removing from list of alternatives update-alternatives: warning: /etc/alternatives/my.cnf is dangling; it will be updated with best choice update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode Renaming removed key_buffer and myisam-recover options (if present) ERROR: Unable to start MySQL server: mysqld: Can’t read dir of ‘/etc/mysql/conf.d/’ (Errcode: 2 - No such file or directory) mysqld: [ERROR] Fatal error in defaults handling. Program aborted! Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgrade issues. Once the problem is resolved, run apt-get —fix-broken install to retry. dpkg: error processing package mysql-server-5.7 (—configure): subprocess installed post-installation script returned error exit status 1 dpkg: dependency problems prevent configuration of mysql-server: mysql-server depends on mysql-server-5.7; however: Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (—configure): dependency problems - leaving unconfigured Processing triggers for systemd (229-4ubuntu12) … Processing triggers for ureadahead (0.100.0-19) … Errors were encountered while processing: mysql-server-5.7 mysql-server E: Sub-process /usr/bin/dpkg returned an error code (1)