MySQLをrpmでインストールする


MySQLをrpmでインストールする | Bamboo lath 日々の記録MySQLをrpmでインストールする

ローカル開発環境で色々なバージョンのmysqlをインストールすることになったのでメモ。

■今入っているmysqlを確認する。

# rpm -qa|grep mysql

■既に入っているmysqlを削除する

# yum remove mysql-*

■インストールしたいバージョンのmysqlを探す

Download MySQL Community Server

MySQL Community Server (Archived Versions)

■作業フォルダにインストールしたいバージョンをダウンロードしてくる

# wget http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-5.1.73-1.glibc23.x86_64.rpm-bundle.tar

■解凍する

# tar xvfp MySQL-5.1.73-1.glibc23.x86_64.rpm-bundle.tar 
MySQL-server-5.1.73-1.glibc23.x86_64.rpm
MySQL-shared-compat-5.1.73-1.glibc23.x86_64.rpm
MySQL-debuginfo-5.1.73-1.glibc23.x86_64.rpm
MySQL-embedded-5.1.73-1.glibc23.x86_64.rpm
MySQL-devel-5.1.73-1.glibc23.x86_64.rpm
MySQL-client-5.1.73-1.glibc23.x86_64.rpm
MySQL-test-5.1.73-1.glibc23.x86_64.rpm
MySQL-shared-5.1.73-1.glibc23.x86_64.rpm

■yum localinstallでまとめてインストールする
※バージョンのところとかは適宜変更。

# yum localinstall MySQL-{client,devel,server,shared-compat}-5.1.73-1.glibc23.x86_64.rpm
Loaded plugins: fastestmirror, versionlock
Setting up Local Package Process
Examining MySQL-client-5.1.73-1.glibc23.x86_64.rpm: MySQL-client-5.1.73-1.glibc23.x86_64
Marking MySQL-client-5.1.73-1.glibc23.x86_64.rpm to be installed
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * epel: ftp.jaist.ac.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
Examining MySQL-devel-5.1.73-1.glibc23.x86_64.rpm: MySQL-devel-5.1.73-1.glibc23.x86_64
Marking MySQL-devel-5.1.73-1.glibc23.x86_64.rpm to be installed
Examining MySQL-server-5.1.73-1.glibc23.x86_64.rpm: MySQL-server-5.1.73-1.glibc23.x86_64
Marking MySQL-server-5.1.73-1.glibc23.x86_64.rpm to be installed
Examining MySQL-shared-compat-5.1.73-1.glibc23.x86_64.rpm: MySQL-shared-compat-5.1.73-1.glibc23.x86_64
Marking MySQL-shared-compat-5.1.73-1.glibc23.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package MySQL-client.x86_64 0:5.1.73-1.glibc23 will be installed
---> Package MySQL-devel.x86_64 0:5.1.73-1.glibc23 will be installed
---> Package MySQL-server.x86_64 0:5.1.73-1.glibc23 will be installed
---> Package MySQL-shared-compat.x86_64 0:5.1.73-1.glibc23 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                            Arch                  Version                          Repository                                                   Size
=============================================================================================================================================================
Installing:
 MySQL-client                       x86_64                5.1.73-1.glibc23                 /MySQL-client-5.1.73-1.glibc23.x86_64                        16 M
 MySQL-devel                        x86_64                5.1.73-1.glibc23                 /MySQL-devel-5.1.73-1.glibc23.x86_64                         30 M
 MySQL-server                       x86_64                5.1.73-1.glibc23                 /MySQL-server-5.1.73-1.glibc23.x86_64                        38 M
 MySQL-shared-compat                x86_64                5.1.73-1.glibc23                 /MySQL-shared-compat-5.1.73-1.glibc23.x86_64                7.0 M

Transaction Summary
=============================================================================================================================================================
Install       4 Package(s)

Total size: 91 M
Installed size: 91 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : MySQL-client-5.1.73-1.glibc23.x86_64                                                                                                      1/4 
  Installing : MySQL-server-5.1.73-1.glibc23.x86_64                                                                                                      2/4 
  Installing : MySQL-devel-5.1.73-1.glibc23.x86_64                                                                                                       3/4 
  Installing : MySQL-shared-compat-5.1.73-1.glibc23.x86_64                                                                                               4/4 
  Verifying  : MySQL-shared-compat-5.1.73-1.glibc23.x86_64                                                                                               1/4 
  Verifying  : MySQL-devel-5.1.73-1.glibc23.x86_64                                                                                                       2/4 
  Verifying  : MySQL-server-5.1.73-1.glibc23.x86_64                                                                                                      3/4 
  Verifying  : MySQL-client-5.1.73-1.glibc23.x86_64                                                                                                      4/4 

Installed:
  MySQL-client.x86_64 0:5.1.73-1.glibc23                   MySQL-devel.x86_64 0:5.1.73-1.glibc23            MySQL-server.x86_64 0:5.1.73-1.glibc23           
  MySQL-shared-compat.x86_64 0:5.1.73-1.glibc23           

Complete!

■既存の残骸が無いように消しておく

# cd /var/lib/mysql/
# pwd
/var/lib/mysql
# rm -rf ./*

■「mysql_install_db」コマンド実行

# mysql_install_db --datadir=/var/lib/mysql --user=mysql
WARNING: The host 'vagrant-centos65.vagrantup.com' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

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 vagrant-centos65.vagrantup.com 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.

You can start the MySQL daemon with:
cd / ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd //mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

■起動

# service mysql start

■パスワード設定

# /usr/bin/mysqladmin -u root password 'パスワード'

■「mysql_secure_installation」コマンドを実行

# /usr/bin/mysql_secure_installation

■mysqlに接続してざっくり設定する。(ローカル用)

mysql> select user, host from mysql.user;
mysql> grant all privileges on *.* to root@'192.168.%' identified by 'パスワード';
mysql> flush privileges;

■文字コードとか設定する
ゴニョゴニョ。
バージョンによる。

■設定変えたので再起動

# service mysql restart

■サービスに登録する

■参考URL

http://www.torutk.com/projects/swe/wiki/CentOS_6%E3%81%A7MySQL_56%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB
http://blog.r-unit.co.jp/archives/964
http://d.hatena.ne.jp/tetsuyai/20110418/1303133792
http://qiita.com/840_/items/06f32fecbe57c3fdf5ec
http://www.infoscoop.org/blogjp/2012/04/18/mysql5-5/

Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist


http://d.hatena.ne.jp/tomoyamkung/20081225/1230165109
http://dev.mysql.com/doc/refman/5.1/ja/mysql-install-db.html

コメントを残す

メールアドレスが公開されることはありません。