04/08 MySQL5.6.23をどうにか動かす

Socketエラーが出てしまい、動かないMySQL5.6.23。psコマンドで見ればmysqldは起動しているし、my.cnfに書いてあるsocketのパスと実際にsocketファイルがある場所もあっている。いろいろ調べたが先に進めないので、MySQLをアンインストールし、再度インストールしたら動くようになった。

まず、古いMySQLが残っているとエラーになる可能性があるので、findで探して削除する。

$ sudo find / -name mysql
/etc/rc.d/init.d/mysql
/etc/logrotate.d/mysql
/var/spool/mail/mysql
/var/log/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/var/lib/mysql_old/mysql
/var/lib/mysql.backup/mysql
/var/lock/subsys/mysql
/usr/include/mysql
/usr/include/mysql/mysql
/usr/share/mysql
/usr/local/fml/databases/mysql
/usr/lib64/mysql
/usr/bin/mysql
/home/masaru/fml-4.0-stable-20040215/databases/mysql
/home/masaru/public_html/phpMyAdmin/js/codemirror/mode/mysql
/home/masaru/phpMyAdmin-3.5.4/js/codemirror/mode/mysql
/home/masaru/php-4.3.10/ext/mysql
/home/masaru/mysql-4.1.10/client/mysql
/home/masaru/mysql-4.1.10/client/.libs/mysql
/home/masaru/php-5.4.9/ext/mysql
/home/masaru/mysql-5.0.16/client/mysql
/home/masaru/mysql-5.0.16/client/.libs/mysql
/home/FROM_OLD_MACHINE/masaru/php-5.0.3/ext/mysql
/home/FROM_OLD_MACHINE/masaru/php-4.3.10/ext/mysql
/home/FROM_OLD_MACHINE/masaru/mysql-4.1.10/client/mysql
/home/FROM_OLD_MACHINE/masaru/mysql-4.1.10/client/.libs/mysql

もう、古いMySQLはばっさり削除してしまおう。

$ sudo rm -R mysql-4.1.10
sudo rm -R mysql-5.0.16

前回作ったmysqlフォルダはリネームする。

$ cd /var/lib
sudo mv mysql mysql201503
cd /etc
sudo cp my.cnf my.cnf.201503

そしてインストールされているMySQLを確認し、アンインストールする。

$ sudo rpm -qa | grep -i ^mysql
MySQL-devel-5.6.23-1.rhel5
MySQL-client-5.6.23-1.rhel5
MySQL-shared-compat-5.6.23-1.rhel5
MySQL-server-5.6.23-1.rhel5
sudo yum erase MySQL-devel-5.6.23-1.rhel5
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package MySQL-devel.x86_64 0:5.6.23-1.rhel5 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================
 Package              Arch            Version                    Repository          Size
==========================================================================================
Removing:
 MySQL-devel          x86_64          5.6.23-1.rhel5             installed           17 M

Transaction Summary
==========================================================================================
Remove        1 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)

Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing        : MySQL-devel                                                        1/1

Removed:
  MySQL-devel.x86_64 0:5.6.23-1.rhel5

Complete!
$ sudo yum erase MySQL-client-5.6.23-1.rhel5
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package MySQL-client.x86_64 0:5.6.23-1.rhel5 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================
 Package               Arch            Version                   Repository          Size
==========================================================================================
Removing:
 MySQL-client          x86_64          5.6.23-1.rhel5            installed           75 M

Transaction Summary
==========================================================================================
Remove        1 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)

Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing        : MySQL-client                                                       1/1

Removed:
  MySQL-client.x86_64 0:5.6.23-1.rhel5

Complete!
$ sudo yum erase MySQL-shared-compat-5.6.23-1.rhel5
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package MySQL-shared-compat.x86_64 0:5.6.23-1.rhel5 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================
 Package                    Arch          Version                  Repository        Size
==========================================================================================
Removing:
 MySQL-shared-compat        x86_64        5.6.23-1.rhel5           installed         11 M

Transaction Summary
==========================================================================================
Remove        1 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)

Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing        : MySQL-shared-compat                                                1/1

Removed:
  MySQL-shared-compat.x86_64 0:5.6.23-1.rhel5

Complete!
$ sudo yum erase MySQL-sever-5.6.23-1.rhel5
Setting up Remove Process
No Match for argument: MySQL-sever-5.6.23-1.rhel5
No Packages marked for removal
[masaru@ns etc]$ sudo yum erase MySQL-server-5.6.23-1.rhel5
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package MySQL-server.x86_64 0:5.6.23-1.rhel5 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================
 Package               Arch            Version                   Repository          Size
==========================================================================================
Removing:
 MySQL-server          x86_64          5.6.23-1.rhel5            installed          253 M

Transaction Summary
==========================================================================================
Remove        1 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)

Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing        : MySQL-server                                                       1/1

Removed:
  MySQL-server.x86_64 0:5.6.23-1.rhel5

Complete!

削除完了。

ここで念のため、yumパッケージにMySQLが入っているか改めて確認したのだが、

$ yum list --enablerepo=remi,epel,usl | grep mysql
apr-util-mysql.x86_64                      1.2.7-11.el5_5.2            base
bacula-director-mysql.x86_64               2.4.4-12.el5                epel
bacula-storage-mysql.x86_64                2.4.4-12.el5                epel
bytefx-data-mysql.x86_64                   1.2.6-6.1.el5               epel
callweaver-mysql.x86_64                    1.2.1-5.el5                 epel
collectd-mysql.x86_64                      4.10.9-1.el5                epel
compat-mysql51.x86_64                      5.1.54-1.el5.remi           remi
compat-mysql51-devel.x86_64                5.1.54-1.el5.remi           remi
dbmail-mysql.x86_64                        2.2.18-1.el5                epel
dmlite-plugins-mysql.x86_64                0.7.2-1.el5                 epel
dpm-copy-server-mysql.x86_64               1.8.9-2.el5                 epel
dpm-name-server-mysql.x86_64               1.8.9-2.el5                 epel
dpm-server-mysql.x86_64                    1.8.9-2.el5                 epel
dpm-srm-server-mysql.x86_64                1.8.9-2.el5                 epel
dspam-mysql.x86_64                         3.10.2-4.el5                epel
freeradius-mysql.x86_64                    1.1.3-1.6.el5               base
freeradius2-mysql.x86_64                   2.1.12-5.el5                base
gnokii-smsd-mysql.x86_64                   0.6.30-2.el5                epel
holland-mysqldump.noarch                   1.0.10-3.el5                epel
holland-mysqllvm.noarch                    1.0.10-3.el5                epel
lfc-server-mysql.x86_64                    1.8.9-2.el5                 epel
libdbi-dbd-mysql.x86_64                    0.8.1a-1.2.2                base
libnss-mysql.i386                          1.5-6.el5                   epel
libnss-mysql.x86_64                        1.5-6.el5                   epel
libodb-mysql.i386                          2.3.0-1.el5                 epel
libodb-mysql.x86_64                        2.3.0-1.el5                 epel
libodb-mysql-devel.i386                    2.3.0-1.el5                 epel
libodb-mysql-devel.x86_64                  2.3.0-1.el5                 epel
lighttpd-mod_mysql_vhost.x86_64            1.4.35-1.el5                epel
lua-sql-mysql.x86_64                       2.1.1-7.el5                 epel
mod_auth_mysql.x86_64                      1:3.0.0-3.2.el5_3           base
mydns-mysql.x86_64                         1.2.8.31-2.el5              epel
mysql.i386                                 5.0.95-5.el5_9              base
mysql.x86_64                               5.5.42-1.el5.remi           remi
mysql++.x86_64                             3.1.0-7.el5.remi            remi
mysql++-devel.x86_64                       3.1.0-7.el5.remi            remi
mysql++-manuals.x86_64                     3.1.0-7.el5.remi            remi
mysql-bench.x86_64                         5.5.42-1.el5.remi           remi
mysql-cluster.x86_64                       5.1.43-1.el5.remi           remi
mysql-connector-c++.x86_64                 1.1.2-1.el5.remi            remi
mysql-connector-c++-devel.x86_64           1.1.2-1.el5.remi            remi
mysql-connector-java.x86_64                1:5.1.12-2.el5              epel
mysql-connector-odbc.x86_64                3.51.26r1127-2.el5          base
mysql-connector-odbc64.x86_64              5.1.8-1.el5                 base
mysql-connector-python.noarch              1.0.12-1.el5.remi           remi
mysql-devel.i386                           5.0.95-5.el5_9              base
mysql-devel.x86_64                         5.5.42-1.el5.remi           remi
mysql-embedded.x86_64                      5.5.42-1.el5.remi           remi
mysql-embedded-devel.x86_64                5.5.42-1.el5.remi           remi
mysql-libs.x86_64                          5.5.42-1.el5.remi           remi
mysql-manual.x86_64                        5.1.38-1.el5.remi           remi
mysql-mmm.noarch                           2.2.1-1.el5                 epel
mysql-mmm-agent.noarch                     2.2.1-1.el5                 epel
mysql-mmm-monitor.noarch                   2.2.1-1.el5                 epel
mysql-mmm-tools.noarch                     2.2.1-1.el5                 epel
mysql-proxy.x86_64                         0.5.1-2.el5                 epel
mysql-server.x86_64                        5.5.42-1.el5.remi           remi
mysql-test.x86_64                          5.5.42-1.el5.remi           remi
mysql51.x86_64                             1-9.el5                     base
mysql51-build.x86_64                       1-9.el5                     base
mysql51-mysql.x86_64                       5.1.70-1.el5                base
mysql51-mysql-bench.x86_64                 5.1.70-1.el5                base
mysql51-mysql-libs.x86_64                  5.1.70-1.el5                base
mysql51-mysql-server.x86_64                5.1.70-1.el5                base
mysql51-mysql-test.x86_64                  5.1.70-1.el5                base
mysql51-runtime.x86_64                     1-9.el5                     base
mysql55.x86_64                             1-12.el5                    base
mysql55-build.x86_64                       1-12.el5                    base
mysql55-mysql.x86_64                       5.5.40-2.el5                updates
mysql55-mysql-bench.x86_64                 5.5.40-2.el5                updates
mysql55-mysql-devel.i386                   5.5.40-2.el5                updates
mysql55-mysql-devel.x86_64                 5.5.40-2.el5                updates
mysql55-mysql-libs.x86_64                  5.5.40-2.el5                updates
mysql55-mysql-server.x86_64                5.5.40-2.el5                updates
mysql55-mysql-test.x86_64                  5.5.40-2.el5                updates
mysql55-runtime.x86_64                     1-12.el5                    base
mysqlclient15.x86_64                       5.0.67-1.el5.remi           remi
mysqlclient15-devel.x86_64                 5.0.67-1.el5.remi           remi
mysqlnd-qc-panel.x86_64                    1.2.0-4.el5.remi.5.4        remi
mysqlreport.noarch                         3.5-2.el5                   epel
mysqltuner.noarch                          1.1.1-1.el5                 epel
nagios-plugins-mysql.x86_64                1.4.15-2.el5                epel
ndoutils-mysql.x86_64                      1.5.2-1.el5                 epel
opensips-mysql.x86_64                      1.7.2-2.el5                 epel
pam_mysql.i386                             1:0.7-0.4.rc1.el5.2         epel
pam_mysql.x86_64                           1:0.7-0.4.rc1.el5.2         epel
pdns-backend-mysql.x86_64                  2.9.22.6-1.el5              epel
php-mysql.x86_64                           5.4.39-1.el5.remi           remi
php-mysqlnd.x86_64                         5.4.39-1.el5.remi           remi
php-pear-MDB2-Driver-mysql.noarch          1.5.0-0.7.b4.el5.remi       remi
php-pear-MDB2-Driver-mysqli.noarch         1.5.0-0.7.b4.el5.remi       remi
php-pecl-mysqlnd-ms.x86_64                 1.5.2-2.el5.remi.5.4        remi
php-pecl-mysqlnd-ms-devel.x86_64           1.5.2-2.el5.remi.5.4        remi
php-pecl-mysqlnd-qc.x86_64                 1.2.0-4.el5.remi.5.4        remi
php-pecl-mysqlnd-qc-devel.x86_64           1.2.0-4.el5.remi.5.4        remi
php53-mysql.x86_64                         5.3.3-26.el5_11             updates
poco-mysql.i386                            1.3.5-9.el5                 epel
poco-mysql.x86_64                          1.3.5-9.el5                 epel
proftpd-mysql.x86_64                       1.3.3g-4.el5                epel
python26-mysqldb.x86_64                    1.2.3-2.el5                 epel
qt4-mysql.x86_64                           4.2.1-1.el5_7.1             base
root-sql-mysql.x86_64                      5.34.26-1.el5               epel
rsyslog-mysql.x86_64                       3.22.1-7.el5                base
rsyslog5-mysql.x86_64                      5.8.12-5.el5_11             updates
ruby-mysql.x86_64                          2.7.3-1.el5                 epel
soci-mysql.i386                            3.1.0-1.el5                 epel
soci-mysql.x86_64                          3.1.0-1.el5                 epel
soci-mysql-devel.i386                      3.1.0-1.el5                 epel
soci-mysql-devel.x86_64                    3.1.0-1.el5                 epel
tcl-mysqltcl.x86_64                        3.05-10.el5                 epel
voms-mysql-plugin.x86_64                   3.1.6-1.el5                 epel[/shell
やはりrpmには5.5までしか入っていない。

JAISTのミラーサイトからダウンロードしておいたMySQL5.6.23のrpmを使ってインストールする。

$ sudo rpm -ivh MySQL-shared-compat-5.6.23-1.rhel5.x86_64.rpm
[sudo] password for masaru:
準備中...                ########################################### [100%]
   1:MySQL-shared-compat    ########################################### [100%]
$ sudo rpm -ivh MySQL-shared-5.6.23-1.rhel5.x86_64.rpm
準備中...                ########################################### [100%]
   1:MySQL-shared           ########################################### [100%]
$ sudo rpm -ivh MySQL-client-5.6.23-1.rhel5.x86_64.rpm
準備中...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
$ sudo rpm -ivh MySQL-devel-5.6.23-1.rhel5.x86_64.rpm
準備中...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]
$ sudo rpm -ivh MySQL-server-5.6.23-1.rhel5.x86_64.rpm
準備中...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
2015-04-08 18:23:35 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-04-08 18:23:35 16604 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-04-08 18:23:35 16604 [Note] InnoDB: The InnoDB memory heap is disabled
2015-04-08 18:23:35 16604 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-04-08 18:23:35 16604 [Note] InnoDB: Memory barrier is not used
2015-04-08 18:23:35 16604 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-04-08 18:23:35 16604 [Note] InnoDB: Using Linux native AIO
2015-04-08 18:23:35 16604 [Note] InnoDB: Not using CPU crc32 instructions
2015-04-08 18:23:35 16604 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-04-08 18:23:35 16604 [Note] InnoDB: Completed initialization of buffer pool
2015-04-08 18:23:35 16604 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-04-08 18:23:35 16604 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-04-08 18:23:35 16604 [Note] InnoDB: Database physically writes the file full: wait...
2015-04-08 18:23:35 16604 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-04-08 18:23:36 16604 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-04-08 18:23:37 16604 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-04-08 18:23:37 16604 [Warning] InnoDB: New log files created, LSN=45781
2015-04-08 18:23:37 16604 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-04-08 18:23:37 16604 [Note] InnoDB: Doublewrite buffer created
2015-04-08 18:23:37 16604 [Note] InnoDB: 128 rollback segment(s) are active.
2015-04-08 18:23:37 16604 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-04-08 18:23:37 16604 [Note] InnoDB: Foreign key constraint system tables created
2015-04-08 18:23:37 16604 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-04-08 18:23:37 16604 [Note] InnoDB: Tablespace and datafile system tables created.
2015-04-08 18:23:37 16604 [Note] InnoDB: Waiting for purge to start
2015-04-08 18:23:37 16604 [Note] InnoDB: 5.6.23 started; log sequence number 0
A random root password has been set. You will find it in '/home/masaru/.mysql_secret'.
2015-04-08 18:23:38 16604 [Note] Binlog end
2015-04-08 18:23:38 16604 [Note] InnoDB: FTS optimize thread exiting.
2015-04-08 18:23:38 16604 [Note] InnoDB: Starting shutdown...
2015-04-08 18:23:39 16604 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2015-04-08 18:23:39 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-04-08 18:23:39 16626 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-04-08 18:23:39 16626 [Note] InnoDB: The InnoDB memory heap is disabled
2015-04-08 18:23:39 16626 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-04-08 18:23:39 16626 [Note] InnoDB: Memory barrier is not used
2015-04-08 18:23:39 16626 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-04-08 18:23:39 16626 [Note] InnoDB: Using Linux native AIO
2015-04-08 18:23:39 16626 [Note] InnoDB: Not using CPU crc32 instructions
2015-04-08 18:23:39 16626 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-04-08 18:23:39 16626 [Note] InnoDB: Completed initialization of buffer pool
2015-04-08 18:23:39 16626 [Note] InnoDB: Highest supported file format is Barracuda.
2015-04-08 18:23:39 16626 [Note] InnoDB: 128 rollback segment(s) are active.
2015-04-08 18:23:39 16626 [Note] InnoDB: Waiting for purge to start
2015-04-08 18:23:39 16626 [Note] InnoDB: 5.6.23 started; log sequence number 1625977
2015-04-08 18:23:39 16626 [Note] Binlog end
2015-04-08 18:23:39 16626 [Note] InnoDB: FTS optimize thread exiting.
2015-04-08 18:23:39 16626 [Note] InnoDB: Starting shutdown...
2015-04-08 18:23:41 16626 [Note] InnoDB: Shutdown completed; log sequence number 1625987




A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/home/masaru/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file /usr/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/my-new.cnf,
please compare it with your file and take the changes you need.

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

ここで大事なメッセージを見逃していた。

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/home/masaru/.mysql_secret'.

つまり、rootのパスワードはランダムな文字列を設定し、それは.mysql_secretに書いてあるよ、というもの。

だから前のパスワードでログインしようとすると

$ sudo /etc/init.d/mysql start
Starting MySQL.                                            [  OK  ]
$ mysql --version
mysql  Ver 14.14 Distrib 5.6.23, for Linux (x86_64) using  EditLine wrapper
$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

となって跳ねられてしまう。

パスワードが分からなくなった場合に準じ、セーフモードでMySQLを起動してパスワードを修正する。

$ sudo /usr/bin/mysqld_safe --skip-grant-tables
150408 18:39:03 mysqld_safe Logging to '/var/log/mysqld.log'.
150408 18:39:03 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

別のターミナルを起動して

$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> UPDATE user SET Password=PASSWORD('hogehogepass') WHERE User='root';
Query OK, 4 rows affected (0.01 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> quit
Bye

だが、これでも入れない。結局、パスワードを「”」とブランクにしたら入ることができた。

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

*

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください