CentOSでMySQLのインストールと設定
remiレポジトリを指定してMySQLのインストール
$ sudo yum --enablerepo=remi install mysql-server Complete! $ mysql --version mysql Ver 14.14 Distrib 5.5.11, for Linux (x86_64) using readline 5.1
関連パッケージをインストールします。
$ sudo yum --enablerepo=remi install php-mbstring php-mysql php-pdo php-mcrypt php-pear Complete!
MySQLの設定ファイルの編集
$ sudo cp /etc/my.cnf /etc/my.cnf.org $ sudo vi /etc/my.cnf
特に変更するところはありませんでした。
起動とサービスに登録する
$ sudo service mysqld start mysqld を起動中: [ OK ] $ sudo chkconfig mysqld on $ chkconfig --list mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
MySQLの初期設定を行う。
$ sudo mysql_secure_installation Enter current password for root (enter for none): Set root password? [Y/n] y New password: Re-enter new password: Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y
動作確認をする。
$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 5.5.11 MySQL Community Server (GPL) by Remi Copyright (c) 2000, 2010, 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> select user,password,host from mysql.user; +------+-------------------------------------------+-----------+ | user | password | host | +------+-------------------------------------------+-----------+ | root | ***************************************** | localhost | | root | ***************************************** | 127.0.0.1 | | root | ***************************************** | ::1 | +------+-------------------------------------------+-----------+ 3 rows in set (0.00 sec) mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.00 sec) mysql> exit Bye
ファイアーウォールの設定と再起動
$ sudo vi /etc/sysconfig/iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT $ sudo service iptables restart