最終更新日:160628
原本
■概要
データベースサーバーは、サーバー上のデータベースをクライアントから操作できるようにするためのサーバー。
ここでは、リレーショナル型データベースのデータベースサーバーであるMySQLを使用する。
■MySQLインストール
[root@dinah ~]# yum -y install mysql-server ← mysql-serverインストール
■MySQL設定
[root@dinah ~]# vi /etc/my.cnf ← MySQL設定ファイル編集
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
default-character-set = utf8 ← 追加(MySQLサーバーの文字コードをUTF-8にする)
validate_password_policy=LOW ← 追加(パスワードの文字数制限を回避)
以下を追加(MySQLクライアントの文字コードをUTF-8にする)
10:[mysql]
11:default-character-set = utf8
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
default-character-set = utf8 ← 追加(MySQLサーバーの文字コードをUTF-8にする)
validate_password_policy=LOW ← 追加(パスワードの文字数制限を回避)
以下を追加(MySQLクライアントの文字コードをUTF-8にする)
10:[mysql]
11:default-character-set = utf8
■MySQL起動
[root@dinah ~]# /etc/rc.d/init.d/mysqld start ← MySQL起動
MySQL データベースを初期化中: Installing all prepared tables
Fill help tables
100128 11:05:04 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
100128 11:05:04 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
OK
Filling help tables...
100128 11:05:05 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
100128 11:05:05 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
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 dinah.uenda.net 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@dinah ~]# chkconfig mysqld on ← MySQL自動起動設定
[root@dinah ~]# chkconfig --list mysqld ← MySQL自動起動設定確認
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← ランレベル2~5のonを確認
MySQL データベースを初期化中: Installing all prepared tables
Fill help tables
100128 11:05:04 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
100128 11:05:04 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
OK
Filling help tables...
100128 11:05:05 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
100128 11:05:05 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
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 dinah.uenda.net 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@dinah ~]# chkconfig mysqld on ← MySQL自動起動設定
[root@dinah ~]# chkconfig --list mysqld ← MySQL自動起動設定確認
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← ランレベル2~5のonを確認
■MySQLデータベース初期設定
(1)rootユーザへのパスワード設定
MySQLの管理ユーザであるrootユーザ(システムのrootユーザとは別)にはデフォルトではパスワードが設定されていないため、パスワードを設定する
[root@dinah ~]# mysql -u root ← MySQLサーバーへrootユーザでログイン
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'New Passward'; ← パスワード変更
mysql> select user,host from mysql.user; ← 登録済ユーザ確認
mysql> grant all on *.* to root@localhost identified by 'xxxxxxMQ';← ホスト名がlocalhostのrootユーザにパスワード設定
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on *.* to root@'%' identified by 'yyyyyyMQ';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from mysql.user; ← 登録済ユーザ、パスワード確認
mysql> exit ← MySQLサーバーからログアウト
Bye
[root@dinah ~]# mysql -u root -h localhost
← ホスト名がlocalhostのrootユーザでパスワードなしでMySQLサーバーへログインできないことを確認
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@dinah ~]# mysql -u root -h 'dinah.uenda.net'
← ホスト名が自ホストのrootユーザでパスワードなしでMySQLサーバーへログインできないことを確認
ERROR 1045 (28000): Access denied for user 'root'@'dinah.uenda.net' (using password: NO)
Welcome to the MySQL monitor. Commands end with ; or \g. ← 未設定
Your MySQL connection id is 5
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
[root@dinah ~]# mysql -u root -h 127.0.0.1
← ホスト名が127.0.0.1のrootユーザでパスワードなしでMySQLサーバーへログインできないことを確認
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@dinah ~]# mysql -u root -h localhost -p ← MySQLへrootでログイン
Enter password: ← MySQLのrootパスワード応答
ホスト名がlocalhostのrootユーザでパスワードありでMySQLサーバーへログインできることを確認
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit ← MySQLサーバーからログアウト
Bye
[root@dinah ~]# mysql -u root -h 'dinah.uenda.net' -p ← 未設定
Enter password: ← MySQLのrootパスワード応答
ホスト名が自ホストのrootユーザでパスワードありでMySQLサーバーへログインできることを確認
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit ← MySQLサーバーからログアウト
Bye
[root@dinah ~]# mysql -u root -h 127.0.0.1 -p ← MySQLへrootでログイン ← 未設定
Enter password: ← MySQLのrootパスワード応答
ホスト名が127.0.0.1のrootユーザでパスワードありでMySQLサーバーへログインできることを確認
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit ← MySQLサーバーからログアウト
Bye
※ホスト名を指定してログインできない場合の対処
ホスト名を指定してログインできない原因は、サーバーが自身のホスト名を名前解決(ホスト名→IPアドレス)できないことが原因。
サーバーが自身のホスト名を名前解決できるように、サーバーの/etc/hostsにホスト名とIPアドレスの対応を追加する。
[root@dinah ~]# grep `hostname` /etc/hosts ← /etc/hostsにホスト名が定義してあるか確認
なにも表示されない=ホスト名が定義されていないことを確認
[root@dinah ~]# echo 127.0.0.1 `hostname` >> /etc/hosts ← /etc/hostsにホスト名の定義を追加
[root@dinah ~]# grep `hostname` /etc/hosts ← /etc/hostsにホスト名が定義してあるか確認
127.0.0.1 dinah.uenda.net ← ホスト名定義追加を確認
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'New Passward'; ← パスワード変更
mysql> select user,host from mysql.user; ← 登録済ユーザ確認
+------+-----------------+ | user | host | +------+-----------------+ | root | localhost | ← ホスト名がlocalhostのrootユーザにパスワードが設定されていない | root | dinah.uenda.net | ← ホスト名が自ホストのrootユーザにパスワードが設定されていない | root | 127.0.0.1 | ← ホスト名が127.0.0.1のrootユーザにパスワードが設定されていない | | localhost | | | dinah.uenda.net | +------+-----------------+5 rows in set (0.00 sec)
mysql> grant all on *.* to root@localhost identified by 'xxxxxxMQ';← ホスト名がlocalhostのrootユーザにパスワード設定
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on *.* to root@'%' identified by 'yyyyyyMQ';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from mysql.user; ← 登録済ユーザ、パスワード確認
+------+-----------------+ | user | host | +------+-----------------+ | root | localhost | ← ホスト名がlocalhostのrootユーザにパスワードが設定された | root | dinah.uenda.net | ← 未設定 | root | 127.0.0.1 | ← ホスト名がlocalhostのrootユーザにパスワードが設定された | | localhost | | | dinah.uenda.net | ← 未設定 | root | % | ← 全てのホストからアクセス可能 +------+-----------------+ 6 rows in set (0.00 sec)
mysql> SHOW VARIABLES LIKE '%ssl%'; ← MySQL 上の SSL 状態の確認
+---------------+----------+ | Variable_name | Value | +---------------+----------+ | have_openssl | DISABLED | | have_ssl | DISABLED | | ssl_ca | | | ssl_capath | | | ssl_cert | | | ssl_cipher | | | ssl_key | | +---------------+----------+ 7 rows in set (0.00 sec)
mysql> exit ← MySQLサーバーからログアウト
Bye
[root@dinah ~]# mysql -u root -h localhost
← ホスト名がlocalhostのrootユーザでパスワードなしでMySQLサーバーへログインできないことを確認
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@dinah ~]# mysql -u root -h 'dinah.uenda.net'
← ホスト名が自ホストのrootユーザでパスワードなしでMySQLサーバーへログインできないことを確認
ERROR 1045 (28000): Access denied for user 'root'@'dinah.uenda.net' (using password: NO)
Welcome to the MySQL monitor. Commands end with ; or \g. ← 未設定
Your MySQL connection id is 5
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
[root@dinah ~]# mysql -u root -h 127.0.0.1
← ホスト名が127.0.0.1のrootユーザでパスワードなしでMySQLサーバーへログインできないことを確認
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@dinah ~]# mysql -u root -h localhost -p ← MySQLへrootでログイン
Enter password: ← MySQLのrootパスワード応答
ホスト名がlocalhostのrootユーザでパスワードありでMySQLサーバーへログインできることを確認
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit ← MySQLサーバーからログアウト
Bye
[root@dinah ~]# mysql -u root -h 'dinah.uenda.net' -p ← 未設定
Enter password: ← MySQLのrootパスワード応答
ホスト名が自ホストのrootユーザでパスワードありでMySQLサーバーへログインできることを確認
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit ← MySQLサーバーからログアウト
Bye
[root@dinah ~]# mysql -u root -h 127.0.0.1 -p ← MySQLへrootでログイン ← 未設定
Enter password: ← MySQLのrootパスワード応答
ホスト名が127.0.0.1のrootユーザでパスワードありでMySQLサーバーへログインできることを確認
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit ← MySQLサーバーからログアウト
Bye
※ホスト名を指定してログインできない場合の対処
ホスト名を指定してログインできない原因は、サーバーが自身のホスト名を名前解決(ホスト名→IPアドレス)できないことが原因。
サーバーが自身のホスト名を名前解決できるように、サーバーの/etc/hostsにホスト名とIPアドレスの対応を追加する。
[root@dinah ~]# grep `hostname` /etc/hosts ← /etc/hostsにホスト名が定義してあるか確認
なにも表示されない=ホスト名が定義されていないことを確認
[root@dinah ~]# echo 127.0.0.1 `hostname` >> /etc/hosts ← /etc/hostsにホスト名の定義を追加
[root@dinah ~]# grep `hostname` /etc/hosts ← /etc/hostsにホスト名が定義してあるか確認
127.0.0.1 dinah.uenda.net ← ホスト名定義追加を確認
(2)testデータベース削除
MySQLにはデフォルトでtestという空のデータベースが登録されているが、不要のため、このデータベースを削除する
[root@dinah ~]# mysql -u root -p ← MySQLへrootでログイン
Enter password: ← MySQLのrootパスワード応答
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases; ← 登録データベース確認
mysql> drop database test; ← testデータベース削除
Query OK, 0 rows affected (0.00 sec)
mysql> show databases; ← 登録データベース確認
mysql> exit ← ログアウト
Bye
Enter password: ← MySQLのrootパスワード応答
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases; ← 登録データベース確認
+--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+3 rows in set (0.00 sec)
mysql> drop database test; ← testデータベース削除
Query OK, 0 rows affected (0.00 sec)
mysql> show databases; ← 登録データベース確認
+--------------------+ | Database | +--------------------+ | information_schema | | mysql | +--------------------+2 rows in set (0.00 sec)
mysql> exit ← ログアウト
Bye
※mysqlデータベースはシステム管理用のデータベースなので削除しないこと
■MySQL確認
[root@dinah ~]# mysql -u root -p ← MySQLへrootでログイン
Enter password: ← MySQLのrootパスワード応答
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
SSLが有効になっているか確認しましょう
mysql > show variables like '%ssl%';
+--------------------------+-------------------------------------+
| Variable_name | Value |
+--------------------------+-------------------------------------+
| have_openssl | YES |
| have_ssl | YES |
| ssl_ca | /etc/mysql-ssl/ca-cert.pem |
| ssl_capath | |
| ssl_cert | /etc/mysql-ssl/server-cert.pem |
| ssl_cipher | |
| ssl_key | /etc/mysql-ssl/server-key.pem |
+--------------------------+------------------------------------+
mysql> grant all privileges on test.* to centos@localhost identified by 'centospass' REQUIRE SSL;
← testデータベースへの全てのアクセス権限を持った、新規ユーザcentosを登録
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on test.* to centos@'%' identified by 'centospass' REQUIRE SSL;
← network経由で、testデータベースへの全てのアクセス権限を持った、新規ユーザcentosを登録
Query OK, 0 rows affected (0.00 sec)
mysql> select user from mysql.user where user='centos'; ← centosユーザ登録確認
mysql> exit ← ログアウト
Bye
[root@dinah ~]# mysql -u centos -pcentospass ← centosユーザでMySQLサーバーへログイン
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database test; ← testデータベース作成
Query OK, 1 row affected (0.00 sec)
mysql> show databases; ← データベース作成確認
mysql> use test ← testデータベースへ接続
Database changed
mysql> create table test(num int, name varchar(50)); ← testテーブル作成
Query OK, 0 rows affected (0.01 sec)
mysql> show tables; ← テーブル作成確認
mysql> insert into test values(1,'山田太郎'); ← testテーブルへデータ登録
Query OK, 1 row affected (0.00 sec)
mysql> select * from test; ← データ登録確認
mysql> update test set name='山田次郎'; ← testテーブル内データ更新
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from test; ← データ更新確認
mysql> delete from test where num=1; ← testテーブル内データ削除
Query OK, 1 row affected (0.03 sec)
mysql> select * from test; ← データ削除確認
Empty set (0.00 sec)
mysql> drop table test; ← testテーブル削除
Query OK, 0 rows affected (0.00 sec)
mysql> show tables; ← テーブル削除確認
Empty set (0.00 sec)
mysql> drop database test; ← データベースtest削除
Query OK, 0 rows affected (0.00 sec)
mysql> show databases; ← データベース削除確認
mysql> exit ← ログアウト
Bye
[root@dinah ~]# mysql -u root -p ← MySQLへrootでログイン
Enter password: ← MySQLのrootパスワード応答
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> revoke all privileges on *.* from centos@localhost; ← centosユーザから全てのデータベースへのアクセス権限を剥奪
Query OK, 0 rows affected (0.00 sec)
mysql> delete from mysql.user where user='centos' and host='localhost'; ← centosユーザ削除
Query OK, 1 row affected (0.01 sec)
mysql> select user from mysql.user where user='centos'; ← centosユーザ削除確認
Empty set (0.00 sec)
mysql> flush privileges; ← centosユーザの削除をMySQLサーバーへ反映
Query OK, 0 rows affected (0.01 sec)
mysql> exit ← ログアウト
Bye
Enter password: ← MySQLのrootパスワード応答
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
SSLが有効になっているか確認しましょう
mysql > show variables like '%ssl%';
+--------------------------+-------------------------------------+
| Variable_name | Value |
+--------------------------+-------------------------------------+
| have_openssl | YES |
| have_ssl | YES |
| ssl_ca | /etc/mysql-ssl/ca-cert.pem |
| ssl_capath | |
| ssl_cert | /etc/mysql-ssl/server-cert.pem |
| ssl_cipher | |
| ssl_key | /etc/mysql-ssl/server-key.pem |
+--------------------------+------------------------------------+
mysql> grant all privileges on test.* to centos@localhost identified by 'centospass' REQUIRE SSL;
← testデータベースへの全てのアクセス権限を持った、新規ユーザcentosを登録
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on test.* to centos@'%' identified by 'centospass' REQUIRE SSL;
← network経由で、testデータベースへの全てのアクセス権限を持った、新規ユーザcentosを登録
Query OK, 0 rows affected (0.00 sec)
mysql> select user from mysql.user where user='centos'; ← centosユーザ登録確認
+--------+ | user | +--------+ | centos | +--------+1 row in set (0.00 sec)
mysql> exit ← ログアウト
Bye
[root@dinah ~]# mysql -u centos -pcentospass ← centosユーザでMySQLサーバーへログイン
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database test; ← testデータベース作成
Query OK, 1 row affected (0.00 sec)
mysql> show databases; ← データベース作成確認
+--------------------+ | Database | +--------------------+ | information_schema | | test | +--------------------+2 rows in set (0.00 sec)
mysql> use test ← testデータベースへ接続
Database changed
mysql> create table test(num int, name varchar(50)); ← testテーブル作成
Query OK, 0 rows affected (0.01 sec)
mysql> show tables; ← テーブル作成確認
+----------------+ | Tables_in_test | +----------------+ | test | +----------------+1 row in set (0.00 sec)
mysql> insert into test values(1,'山田太郎'); ← testテーブルへデータ登録
Query OK, 1 row affected (0.00 sec)
mysql> select * from test; ← データ登録確認
+------+----------+ | num | name | +------+----------+ | 1 | 山田太郎 | +------+----------+1 row in set (0.00 sec)
mysql> update test set name='山田次郎'; ← testテーブル内データ更新
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from test; ← データ更新確認
+------+----------+ | num | name | +------+----------+ | 1 | 山田次郎 | +------+----------+1 row in set (0.01 sec)
mysql> delete from test where num=1; ← testテーブル内データ削除
Query OK, 1 row affected (0.03 sec)
mysql> select * from test; ← データ削除確認
Empty set (0.00 sec)
mysql> drop table test; ← testテーブル削除
Query OK, 0 rows affected (0.00 sec)
mysql> show tables; ← テーブル削除確認
Empty set (0.00 sec)
mysql> drop database test; ← データベースtest削除
Query OK, 0 rows affected (0.00 sec)
mysql> show databases; ← データベース削除確認
+--------------------+ | Database | +--------------------+ | information_schema | +--------------------+1 row in set (0.00 sec)
mysql> exit ← ログアウト
Bye
[root@dinah ~]# mysql -u root -p ← MySQLへrootでログイン
Enter password: ← MySQLのrootパスワード応答
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> revoke all privileges on *.* from centos@localhost; ← centosユーザから全てのデータベースへのアクセス権限を剥奪
Query OK, 0 rows affected (0.00 sec)
mysql> delete from mysql.user where user='centos' and host='localhost'; ← centosユーザ削除
Query OK, 1 row affected (0.01 sec)
mysql> select user from mysql.user where user='centos'; ← centosユーザ削除確認
Empty set (0.00 sec)
mysql> flush privileges; ← centosユーザの削除をMySQLサーバーへ反映
Query OK, 0 rows affected (0.01 sec)
mysql> exit ← ログアウト
Bye