MySQL/CentOSにMySQLをインストール
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* CentOSにMySQLをインストール [#l48f665f]
CentOS6にMySQLをインストールしたときの備忘録です。
#contents
#htmlinsertpcsp(db-top.html,db-sp.html)
* 関連資料 [#wd458664]
-[[WindowsにMySQL5.5をインストール>MySQL/WindowsにMySQL5....
* CentOS6にMySQLをインストール [#c66e86a8]
yumコマンドを利用してMySQLパッケージをインストールしまし...
以下のコマンドでインストールすることができます。
yum -y install mysql-server
*default-character-setをutf8に変更する [#t1051b06]
インストール後、rootにてmysqlコマンドを利用してcharacter_...
[root@centos6 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.61 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. ...
Oracle is a registered trademark of Oracle Corporation a...
affiliates. Other names may be trademarks of their respe...
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the cu...
mysql> show variables like "char%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
** /etc/my.cnfに追記 [#a1fd54f4]
character-set-server = utf8を追記する。
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent ass...
symbolic-links=0
character-set-server = utf8
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
追記してmysqldを再起動した後の結果です。~
character_set_database, character_set_serverがutf8に変更...
mysql> show variables like "char%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)
character_set_clientなども変更したい場合は、
[mysql]
default-character-set=utf8
を/etc/my.cnfに追記してください。
* mysql_secure_installationによる初期設定 [#beef9f9f]
yumコマンドによりmysqldをインストールした後、以下のコマン...
- mysqldの起動
service mysqld start
- mysqld初回起動時のメッセージ
[root@centos6 ~]# service mysqld start
MySQL データベースを初期化中: WARNING: The host 'centos...
This probably means that your libc libraries are not 100...
with this binary MySQL version. The MySQL daemon, mysqld...
normally with the exception that host name resolving wil...
This means that you should use IP addresses instead of h...
when specifying MySQL privileges !
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 s...
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USE...
To do so, start the server, then issue the following com...
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h centos6 password 'new-pas...
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 sc...
** mysql_secure_installationを実行する [#i4c020a9]
mysql_secure_installationにより、MySQLの設定(セキュリティ...
mysql_secure_installationを調べると、シェルスクリプトのよ...
[root@centos6 ~]# file `which mysql_secure_installation`
/usr/bin/mysql_secure_installation: POSIX shell script t...
** mysql_secure_installationを実行してみる [#m17554b0]
mysql_secure_installationを実行したときの出力です。
[root@centos6 ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FO...
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP ...
In order to log into MySQL to secure it, we'll need the ...
password for the root user. If you've just installed My...
you haven't set the root password yet, the password will...
so you should just press enter here.
Enter current password for root (enter for none):
MySQLのrootパスワードを入力します。~
設定していないので、Enterキーを押します。
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log in...
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
デフォルトではYになっていますが、一応Yを入力しました。~
MySQLのrootパスワードを設定します。
By default, a MySQL installation has an anonymous user, ...
to log into MySQL without having to have a user account ...
them. This is intended only for testing, and to make th...
go a bit smoother. You should remove them before moving...
production environment.
Remove anonymous users? [Y/n] Y
... Success!
匿名ユーザの削除をするか聞かれたのでYを入力しEnterで削除...
Normally, root should only be allowed to connect from 'l...
ensures that someone cannot guess at the root password f...
Disallow root login remotely? [Y/n] Y
... Success!
外部からのrootによるログインを許可するかを聞いてきたのでY...
By default, MySQL comes with a database named 'test' that...
access. This is also intended only for testing, and shou...
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
testデータベースの削除をするのか?と聞いてきたのでYを押し...
Reloading the privilege tables will ensure that all chan...
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
設定の反映を行うか?と聞いてきたのでYを押してEnterで設定...
Cleaning up...
All done! If you've completed all of the above steps, y...
installation should now be secure.
Thanks for using MySQL!
* MySQLをサーバ立ち上げ時に自動起動にする [#d80b7cea]
CentOSではcheckconfigコマンドによりon/offすることができま...
以下のコマンドにより、mysqldをサーバ立ち上げ時にon/offす...
本コマンドはrootユーザで実行してください。
- onにする
chkconfig mysqld on
- offにする
chkconfig mysqld off
- 設定を確認する
chkconfig --list | grep mysql
* MySQLにログインしてみる [#sd8ba1bc]
以下のコマンドでMySQLにログインしてみます。
mysql -u root -p
Enter Passwordで入力するパスワードは、上記のmysql_secure_...
[sakura@centos6 ~]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.1.61 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. ...
Oracle is a registered trademark of Oracle Corporation a...
affiliates. Other names may be trademarks of their respe...
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the cu...
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.00 sec)
#htmlinsertpcsp(db-btm.html,db-sp.html)
終了行:
#navi(../)
* CentOSにMySQLをインストール [#l48f665f]
CentOS6にMySQLをインストールしたときの備忘録です。
#contents
#htmlinsertpcsp(db-top.html,db-sp.html)
* 関連資料 [#wd458664]
-[[WindowsにMySQL5.5をインストール>MySQL/WindowsにMySQL5....
* CentOS6にMySQLをインストール [#c66e86a8]
yumコマンドを利用してMySQLパッケージをインストールしまし...
以下のコマンドでインストールすることができます。
yum -y install mysql-server
*default-character-setをutf8に変更する [#t1051b06]
インストール後、rootにてmysqlコマンドを利用してcharacter_...
[root@centos6 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.61 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. ...
Oracle is a registered trademark of Oracle Corporation a...
affiliates. Other names may be trademarks of their respe...
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the cu...
mysql> show variables like "char%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
** /etc/my.cnfに追記 [#a1fd54f4]
character-set-server = utf8を追記する。
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent ass...
symbolic-links=0
character-set-server = utf8
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
追記してmysqldを再起動した後の結果です。~
character_set_database, character_set_serverがutf8に変更...
mysql> show variables like "char%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)
character_set_clientなども変更したい場合は、
[mysql]
default-character-set=utf8
を/etc/my.cnfに追記してください。
* mysql_secure_installationによる初期設定 [#beef9f9f]
yumコマンドによりmysqldをインストールした後、以下のコマン...
- mysqldの起動
service mysqld start
- mysqld初回起動時のメッセージ
[root@centos6 ~]# service mysqld start
MySQL データベースを初期化中: WARNING: The host 'centos...
This probably means that your libc libraries are not 100...
with this binary MySQL version. The MySQL daemon, mysqld...
normally with the exception that host name resolving wil...
This means that you should use IP addresses instead of h...
when specifying MySQL privileges !
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 s...
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USE...
To do so, start the server, then issue the following com...
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h centos6 password 'new-pas...
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 sc...
** mysql_secure_installationを実行する [#i4c020a9]
mysql_secure_installationにより、MySQLの設定(セキュリティ...
mysql_secure_installationを調べると、シェルスクリプトのよ...
[root@centos6 ~]# file `which mysql_secure_installation`
/usr/bin/mysql_secure_installation: POSIX shell script t...
** mysql_secure_installationを実行してみる [#m17554b0]
mysql_secure_installationを実行したときの出力です。
[root@centos6 ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FO...
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP ...
In order to log into MySQL to secure it, we'll need the ...
password for the root user. If you've just installed My...
you haven't set the root password yet, the password will...
so you should just press enter here.
Enter current password for root (enter for none):
MySQLのrootパスワードを入力します。~
設定していないので、Enterキーを押します。
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log in...
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
デフォルトではYになっていますが、一応Yを入力しました。~
MySQLのrootパスワードを設定します。
By default, a MySQL installation has an anonymous user, ...
to log into MySQL without having to have a user account ...
them. This is intended only for testing, and to make th...
go a bit smoother. You should remove them before moving...
production environment.
Remove anonymous users? [Y/n] Y
... Success!
匿名ユーザの削除をするか聞かれたのでYを入力しEnterで削除...
Normally, root should only be allowed to connect from 'l...
ensures that someone cannot guess at the root password f...
Disallow root login remotely? [Y/n] Y
... Success!
外部からのrootによるログインを許可するかを聞いてきたのでY...
By default, MySQL comes with a database named 'test' that...
access. This is also intended only for testing, and shou...
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
testデータベースの削除をするのか?と聞いてきたのでYを押し...
Reloading the privilege tables will ensure that all chan...
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
設定の反映を行うか?と聞いてきたのでYを押してEnterで設定...
Cleaning up...
All done! If you've completed all of the above steps, y...
installation should now be secure.
Thanks for using MySQL!
* MySQLをサーバ立ち上げ時に自動起動にする [#d80b7cea]
CentOSではcheckconfigコマンドによりon/offすることができま...
以下のコマンドにより、mysqldをサーバ立ち上げ時にon/offす...
本コマンドはrootユーザで実行してください。
- onにする
chkconfig mysqld on
- offにする
chkconfig mysqld off
- 設定を確認する
chkconfig --list | grep mysql
* MySQLにログインしてみる [#sd8ba1bc]
以下のコマンドでMySQLにログインしてみます。
mysql -u root -p
Enter Passwordで入力するパスワードは、上記のmysql_secure_...
[sakura@centos6 ~]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.1.61 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. ...
Oracle is a registered trademark of Oracle Corporation a...
affiliates. Other names may be trademarks of their respe...
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the cu...
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.00 sec)
#htmlinsertpcsp(db-btm.html,db-sp.html)
ページ名: