MySQL5.6.40をソースコードからインストールしてみる
仕事先で使っているCentOS6.5にMySQL 5.6.xの最新を
再インストールしようとしてyumからバイナリで実行したら
見事に、稀に見る起動できないパターンで、いろいろ調べて
対応したけど、どうにもならなかったので今回はソース
コードから再々インストールにチャレンジしてみるテストw
cmakeとncurses-develもソースコードからインストールする
という記事を見てそこから始めようと思ったが、そのURL
を思い出せなくて時間がかかったので、yumでバイナリを
インストールすることで対応したw(ΦωΦ;)
gitの最新版もソースコードをビルドしてインストールしたから
MySQLもあわよくばそれでいいよねって思ったw
まぁビルドに成功するといいな。
話はまずそれからだwww
[手順]
# wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.40.tar.gz
2. /usr/local/src に移動し、tarで展開。
# cd /usr/local/src
# tar zvxf mysql-5.6.40.tar.gz
3. yumでcmakeとncurses-develをインストール。
# yum install cmake ncurses-devel
4. cmake実行。
# cmake . -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_SSL=bundled
5. make実行。
# make
6. make install実行。
# make install
7. mysqlのグループとユーザーを作成し権限を変更。
# groupadd mysql
8. データディレクトリを作成して、初期化し、権限を変更。
# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
9. 自動起動の設定。
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
# chmod +x /etc/init.d/mysql
# chkconfig --add mysql
10. ランレベルの設定を確認。
# chkconfig --list | grep mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
11. 起動スクリプトの変更。
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
12. サービスの起動。
# service mysql start
13. エラーが発生して起動しなかったら、my.cnf修正で対応。
/etc/my.cnfのバックアップを削除して、/usr/local/mysql/に
自動作成されていたものを採用。
ちなみに、メッセージがわかりづらいw(ΦωΦ)
Starting MySQL... ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).
(ex) portはclientとserverで別の番号を指定。
[client]
client.port = 3306
[mysqld]
mysqld.port = 3307
14. エラーなくサービスが起動することを確認。
# service mysql start
Starting MySQL. SUCCESS!
15. クライアントを起動してrootのパスワードを設定。
# /usr/local/mysql/bin/mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.40-log Source distribution
Copyright (c) 2000, 2018, 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> SET PASSWORD FORroot@localhost=PASSWORD('設定するrootのパスワード');
Query OK, 0 rows affected (0.00 sec)
[参考サイト]