さくらVPS WordPress 移設・移転・引っ越し方法 (3) MySQLデータベースを新規作成する方法

 ← (2) データベースのエクスポート からの続きです。
 
 さて、ダウンロード作業お疲れ様です。
 その、ダウンロード中でも良いので、さくらVPS(新サーバー)側の準備を進めましょう。
 まずは、MySQL のインストール、起動、ユーザー名設定、パスワード設定、データベース作成を行います。

 Tera Team など ターミナルエミュレーター より、新サーバーに接続して、ルート権限に変更します。
[text]
 su –
[/text]
 次に、yum コマンドを使って、MySQL を新サーバーにインストールします。
[text]
 yum -y install mysql-server
[/text]
 インストールしたら、MySQL設定ファイル編集して、WordPressが表示される文字コード UTF-8 にします。
[text]
 vi /etc/my.cnf
[/text]
[text]
[mysqld]
 datadir=/var/lib/mysql
 socket=/var/lib/mysql/mysql.sock
 user=mysql
 # Disabling symbolic-links is recommended to prevent assorted security risks
 symbolic-links=0
 character-set-server = utf8    ←追加(MySQLサーバーの文字コードをUTF-8にする)
[/text]
 ※編集用のコマンドに不慣れな方はこちらもご覧ください。
 設定を上書き保存したら、MySQLを実行させます。
[text]
 service mysqld start
[/text]
 起動中 : [ok]
 と表示されたら、以後、サーバー再起動した際に自動起動されるように設定しておきます。
[text]
chkconfig mysqld on
[/text]
 ※エンターしても、特に何も表示されませんが大丈夫です。

■MySQL初期設定

 次に、WordPressのデータベースとして使えるように、MySQLの初期設定を行います。
[text]
 mysql_secure_installation
[/text]
[text]
OTE: 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):  ← 空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]  ← 空ENTER(rootパスワード設定)
New password:  ← rootパスワード設定する ※入力しても見えません
Re-enter new password:  ← rootパスワード再度入力 ※入力しても見えません
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]  ← 空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]  ← 空ENTER(リモートからのrootログイン禁止)
… Success!

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]  ← 空ENTER(testデータベース削除)
– 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]  ← 空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!
[/text]

 続けて、MySQL に ユーザー名 root で直接入って、データベース内の設定をします。
[text]
 mysql -u root -p
[/tex]
 パスワードを聞かれますので、先ほど設定した MySQL用のパスワードを入力。
 MySQL に無事に入れると、左側の権限表示 [root@***** ~]が、MySQLに入った事を示す
[text]
 mysql>
[/text]
に変わりますので、rootユーザーを確認してみます。
[text]
 select user from mysql.user where user=’root’;
[/text]
 次に、WordPressを入れるデータベースを新規作成します。
 下記の例は  yamada と言うデータベースの名前で作る例ですので、お好みで変えて下さい。
[text]
 create database yamada;
[/text]
データベースができたか、確認してみます。
[text]
 show databases;
[/text]
 もし、初期で作られている text データベースなどが不要でしたら、下記のような記述例で削除しても良いです。
[text]
 drop database test;
[/text]
 さて、作成したデータベースの文字コードを UTF-8 に設定しておきます。
 同じく下記は記述例ですので yamada の箇所は、作ったデータベース名に変えて入力願います。
[text]
 create database yamada character set utf8 collate utf8_bin;
[/text]
 データベースに接続できるユーザー名とパスワードを作成します。
 同じく下記の yamada の箇所は作ったデータベース名でお願いします。
 パスワード の箇所は英数半角に変えて下さい。
[text]
 grant all privileges on yamada.* to root@localhost identified by ‘パスワード’;
[/text]
 設定をMySQLに反映。
[text]
 flush privileges;
[/text]
 そしたら、MySQLよりログアウトします。
[text]
 exit
[/text]
 すると、 Bye と表示されて、 [root@***** ~] の状態に戻りますので、
 MySQL 再起動 しましょう。
[text]
 service mysqld restart
[/text]

 これで、WordPress用の
 「データベース名」
 「ユーザー名」
 「パスワード」
 が作れたと思いますので、忘れずにメモなどしておいてください。

 うまく行かない場合には下記サイトなども参考になるかと存じます。
 http://centossrv.com/mysql.shtml

 ・ (4) phpmyadmin をインストール に続きます。

 引用元はこちら


スポンサーリンク



スポンサーリンク



関連記事

コメント

  • トラックバックは利用できません。

  • コメント (0)

  1. この記事へのコメントはありません。

コメントは利用できません。

ページ上部へ戻る