2011年12月8日木曜日

DBサーバ構築


1.MySQLサーバのインストール

#yum install mysql-server



2.MySQLサーバを,サーバ起動時に自動的に起動するように設定

#chkconfig mysqld on


3.MySQLサーバの起動
(自動起動設定が反映された次回起動以降であれば,このようなコマンドは不要ですが,今回は自動起動はなされていないため,手動にてMySQLサーバを起動)

#service mysqld start



4.MySQLサーバの初期設定
セキュリティーを確保するために,何カ所かの設定変更が必要です.
従来は個別に設定を施していましたが,それらを纏めて設定する便利な対話式のツールがあるので,今回はそちらを利用します.
(もちろん個別に設定を行ってもかまいません)

#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):

*1 初期状態ではrootにパスワードは設定されていない為,何も入力せずenter

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

*2 rootのパスワードを設定するために,Yを入力後enter

New password:********

*3 設定したいパスワードを入力後enter

Re-enter new password:********

*4 再度設定したいパスワードを入力しenter

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

*5 初期状態で登録されている匿名ユーザーを削除する為にYを入力しenter

... 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] n

*6 初期状態で設定されている外部からのrootアカウントでのログイン設定.今回はrootでのログインを許可する方針の為nを選択しenter

... 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] Y

*7 初期状態で用意されているtestテーブルを削除する為にYを入力しenter

- 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 now? [Y/n] Y

*8 設定ファイルを再読込するために,Yを入力しenter

... 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!

5.コマンドラインからMySQLサーバに接続

#mysql -u root -p


6.MySQL Workbenchから接続

Windowsで使用できるGUIツールであるMySQL Workbenchをインストール
Download

Server Administration -> New Server Instanceから接続設定作成






0 件のコメント: