■先ずシステムのアップデートを行った。
[root@localhost ~]# yum update
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-274.3.1.el5 #1 SMP Tue Sep 6 20:13:52 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
■MySQLサーバーと、そのクライアントツールのインストールを行った。
[root@localhost ~]# yum install mysql-server mysql
========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
mysql i386 5.0.77-4.el5_6.6 base 4.8 M
mysql x86_64 5.0.77-4.el5_6.6 base 4.8 M
mysql-server x86_64 5.0.77-4.el5_6.6 base 9.8 M
Installing for dependencies:
perl-DBD-MySQL x86_64 3.0007-2.el5 base 148 k
perl-DBI x86_64 1.52-2.el5 base 600 k
Transaction Summary
========================================================================================================================================================================
Install 5 Package(s)
Upgrade 0 Package(s)
Total download size: 20 M
Installed:
mysql.i386 0:5.0.77-4.el5_6.6 mysql.x86_64 0:5.0.77-4.el5_6.6 mysql-server.x86_64 0:5.0.77-4.el5_6.6
Dependency Installed:
perl-DBD-MySQL.x86_64 0:3.0007-2.el5 perl-DBI.x86_64 0:1.52-2.el5
Complete!
■MySQLサーバーを自動起動させる設定を行う
[root@localhost ~]# chkconfig mysqld on
[root@localhost ~]# chkconfig --list | grep mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost ~]#
■MySQLサーバーを起動する
初回では、案内のメッセージが表示された。
[root@localhost ~]# service mysqld start
MySQL データベースを初期化中: 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 localhost.localdomain 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 ; /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!
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
[ OK ]
MySQL を起動中: [ OK ]
[root@localhost ~]#
■MySQLサーバーのセットアップを行う
[root@localhost ~]# /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): ←インストールしたばかりで、MySQLのrootパスワードが未決定なので、そのままエンターを押す。
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y ←MySQLのrootパスワードを設定したいので、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 ←セキュリティーのため匿名ユーザーを許可しない場合は、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] ←rootユーザーのリモートログインを認めるなら、nを押す。
... skipping.
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] n ←テスト用のデータベースを削除したくないなら、nを押す。
... skipping.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y ←ここまでの設定内容を反映する場合は、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!
[root@localhost ~]#
■MySQLサーバーにログインできるか試す
[root@localhost ~]# mysql -u root -p ←rootユーザーでログインを試みる
Enter password: ←上のセットアップで設定したパスワードを入力する
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
mysql> exit ←mysqlのコマンドプロンプトを終了する
Bye
[root@localhost ~]#
◎MySQLの管理・操作GUIを提供するphpMyAdminのインストール方法はこちらです。
http://akira-arets.blogspot.com/2011/11/linux-centos-57-phpmyadminyum.html