WebARENAのVPSクラウドには初期状態で「MySQL」というデータベースプログラムがインストールされています。「MySQL」を使用してデータベースサーバーを構築する場合はMySQLの設定を行って下さい。
オンラインマニュアルに記載されていない設定については弊社のサポート対象外となります。この例と異なるご利用形態でお使いになる場合はMySQLの設定方法について解説されている書籍・Webサイトなどをご参考に お客さまにて設定ファイルの内容を書き換えてご利用下さい。
[root@example ~]# service mysqld start Initializing MySQL database: 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 example.com 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 /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! [ OK ] Starting mysqld: [ OK ]
[root@example ~]# mysqladmin -u root password パスワード
[root@example ~]# mysql -u root -p Enter password: (パスワード) Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.1.67 Source distribution . . . Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql > SET PASSWORD FOR root@127.0.0.1=password('パスワード');
Query OK, 0 rows affected (0.00 sec)
mysql > SET PASSWORD FOR root@ホスト名=password('パスワード');
Query OK, 0 rows affected (0.00 sec)
※ホスト名情報は以下コマンドにて確認できます。(以下example.comの場合)
mysql> USE mysql; Database changed mysql> SELECT user,host,password FROM mysql.user; +------+--------------+-------------------------------------------+ | user | host | password | +------+--------------+-------------------------------------------+ | root | localhost | *423B4F064CE2852B55AEC8E09CC8AFC135991862 | | root | example.com. | *35417AD9696FC8B598835E0795D218F1AF4C717F | | root | 127.0.0.1 | *DE8EB47E628634A63A4FE22274348660EC434DF4 | +------+--------------+-------------------------------------------+ 5 rows in set (0.00 sec)
続けて、データベースとユーザを作成します。
mysql>CREATE DATABASE data1 DEFAULT CHAR SET UTF8;
Query OK, 1 row affected (0.00 sec)
mysql>SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| data1 |
| mysql |
| test |
+--------------------+
mysql> GRANT ALL ON data1.* TO dbuser@localhost IDENTIFIED BY 'パスワード';
Query OK, 0 rows affected (0.00 sec)
OSの再起動と同時にMySQLを自動起動したい場合は、chkconfig でmysqldをon に設定して下さい。chkconfig の設定方法は、オンラインマニュアル内 サービスの自動起動設定に掲載しておりますのでご参照下さい。
以上で基本的なMySQLの設定は完了です。
MySQLのrootパスワードを紛失した場合も、以下の手順で再設定が行えます。
[root@example ~]#service mysqld stop Stopping MySQL: [ OK ]
[root@example ~]#/usr/bin/mysqld_safe --user=root --skip-grant-tables & [1] 5128 [root@example ~]# Starting mysqld daemon with databases from /var/lib/mysql [root@example ~]# mysql mysql
mysql>update user set password=null where host='localhost' and user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
※この時点でroot@localhostのパスワードは以下のように空白になっています。
mysql>USE mysql; Database changed mysql>SELECT user,host,password FROM mysql.user; +--------+--------------+-------------------------------------------+ | user | host | password | +--------+--------------+-------------------------------------------+ | root | localhost | | | root | example.com. | *35417AD9696FC8B598835E0795D218F1AF4C717F | | root | 127.0.0.1 | *DE8EB47E628634A63A4FE22274348660EC434DF4 | | dbuser | localhost | *423B4F064CE2852B55AEC8E09CC8AFC135991862 | +--------+--------------+-------------------------------------------+
mysql> QUIT; Bye [root@example ~]# service mysqld restart
[root@example ~]# mysql -u root mysql> set password for root@localhost=password('新しいパスワード');