さくらのVPS

MySQLのインストール

  • 最新のMySQL5.5をインストールする。
  • remiリポジトリを利用する。

(参考)
http://d.hatena.ne.jp/renmen/20101027/1288111712

MySQLの有無確認

whereis mysql

インストール

  • リポジトリ内のバージョン確認
# yum info mysql --enablerepo=remi                                           
# yum info mysql-server --enablerepo=remi
(# yum info mysql --enablerepo=remi-test)
(# yum info mysql-server --enablerepo=remi-test)
  • yumでインストール
# yum --enablerepo=remi,remi-test install mysqlclient15 mysql.x86_64 mysql-server mysql-lib
  • インストールされたMySQLの内容を確認する
# rpm -qa | grep mysql | sort

以下のような表示が出てくればOK

mysql-5.5.10-1.el5.remi
mysql-libs-5.5.10-1.el5.remi
mysql-server-5.5.10-1.el5.remi
mysqlclient15-5.0.67-1.el5.remi
  • 念のため、MySQLが入っている場所も再度チェックする
# whereis mysql

以下の場所に、MySQL関連のデータが入ってました。

mysql: /usr/bin/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

初期化

(参考)
http://akibe.com/2010/09/centos-setup-7-mysql/

# mysql_install_db ← 明示的に初期化(やらなくてもOK)

MySQL起動、自動起動の設定

# /etc/rc.d/init.d/mysqld start
# chkconfig mysqld on
# chkconfig --list mysqld

MySQLの設定

# vi /etc/my.cnf
  • 「mysqld」の項目に以下を追加
[mysqld]
:
default-character-set=utf8
skip-character-set-client-handshake

(参考)MySQL5.5では、上記の内容だとエラーになる。
http://kawama.jp/archives/2011/02/mysql5-5_character-set-server.html

[mysqld]
character-set-server = utf8
skip-character-set-client-handshake

MySQL5.5では、「default-character-set」ではなく、「character-set-server」に変更されている。

MySQLを再起動

# /etc/rc.d/init.d/mysqld restart

rootユーザーのパスワード設定

# mysqladmin -u root password 'パスワード' ← (展望)

ログイン

# mysql -u root -p
  • MySQLのユーザー確認
mysql> select user,host,password from mysql.user;
mysql> exit;

セキュリティーの設定

(参考)
http://sabakan.org/p/blog/2011/01/17/mysql_secure_installation/

MySQL設定のセキュリティーチェック&修正をしてくれる便利なコマンド「mysql_secure_installation」を使う。

# /usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
  SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
 
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
 
Enter current password for root (enter for none):

OK, successfully used password, moving on...
 
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
 
You already have a root password set, so you can safely answer 'n'.
 
Change the root password? [Y/n]

「y」

New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
 
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
 
Remove anonymous users? [Y/n]

「y」

... Success!
 
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
 
Disallow root login remotely? [Y/n]

「y」

... Success!
 
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
 
Remove test database and access to it? [Y/n]

「y」

- Dropping test database...
... Success!

- Removing privileges on test database...
... Success!
 
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
 
Reload privilege tables 2011-05-02 (月) 13:08:23 [Y/n]

「y」

... Success!
 
Cleaning up...

All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
 
Thanks for using MySQL!

MySQLの削除

(参考)
http://kajuhome.com/cgi-bin/patio/patio.cgi?mode=view&no=424

  • MySQLの確認
# rpm -qa | grep mysql | sort 
# whereis mysql
  • MySQLの削除
# yum remove mysql
# rm -Rf /usr/share/mysql

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2011-05-02 (月) 13:41:36 (4735d)