Contents
Overview
CentOS 5 における MySQL データベースサーバーの構築手順です。
インストール
mysql-server
をインストールします。
[root@centos-5 ~]# yum -y install mysql-server
/etc/my.cnf
/etc/my.cnf
をバックアップし、エディターで開きます。
[root@centos-5 ~]# cp /etc/my.cnf /etc/my.cnf.orig
[root@centos-5 ~]# vim /etc/my.cnf
/etc/my.cnf
を編集します。デフォルトの文字セットを utf8
に設定しています。
[mysqld]
default-character-set = utf8
[mysql]
default-character-set = utf8
サービス起動設定
mysqld
サービスを起動し、システムの起動時に有効になるように設定します。
[root@centos-5 ~]# service mysqld start && chkconfig mysqld on
[root@centos-5 ~]# chkconfig mysqld --list
初期設定
MySQL の初期設定を行います。
ログイン
ログインします。
[root@centos-5 ~]# mysql -u root
ユーザ一覧
ユーザーの一覧を確認します。
mysql> select user,host,password from mysql.user;
root ユーザーのパスワード設定
root ユーザーのパスワードを設定します。root ユーザーはアクセス元のホストの応じて複数存在します。この例では、パスワードに password
を指定しています。
mysql> set password for root@localhost=password('password');
mysql> set password for root@'centos-5'=password('password');
mysql> set password for root@'127.0.0.1'=password('password');
匿名ユーザーを削除
匿名ユーザーを削除します。
mysql> delete from mysql.user where user='';
データベース一覧
データベースの一覧を確認します。
mysql> show databases;
test データベース削除
test データベースを削除します。
mysql> drop database test;
ログアウト
MySQL からログアウトします。
mysql> quit;
CentOS 5 MySQL データベースサーバー構築