サンプル集 |
■VC ■C# ■Java ■BorlandC ■LinuxC ■MS-DOS ■bash ■Excel VBA ■VBScript ■PHP ■HTML ■perl ■iPhone ■Android ■Lua ■other |
Linuxコマンド |
用語集 |
debian メモ |
apache2 メモ |
MySQL メモ |
Oracle メモ |
HOME |
Windows Azure上の CentOS の仮想マシンに MySQL をインストールします。
◆環境OS | CentOS 2.6.32-431.17.1.el6.x86_64 #1 SMP Wed May 7 23:32:49 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux |
---|---|
MySQL | 5.1.73 Source distribution |
MySQLのインストールはyumで行います。
$ sudo yum install mysql-server
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for azureuser:
Loaded plugins: security
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
openlogic | 1.3 kB 00:00
openlogic/primary | 273 kB 00:00
openlogic 27/27
updates | 3.4 kB 00:00
updates/primary_db | 3.2 MB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.x86_64 0:5.1.73-3.el6_5 will be installed
--> Processing Dependency: mysql = 5.1.73-3.el6_5 for package: mysql-se
rver-5.1.73-3.el6_5.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1
.73-3.el6_5.x86_64
--> Running transaction check
---> Package mysql.x86_64 0:5.1.73-3.el6_5 will be installed
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================
Package Arch Version Repository Size
=======================================================================
Installing:
mysql-server x86_64 5.1.73-3.el6_5 updates 8.6 M
Installing for dependencies:
mysql x86_64 5.1.73-3.el6_5 updates 894 k
perl-DBD-MySQL x86_64 4.013-3.el6 base 134 k
Transaction Summary
=======================================================================
Install 3 Package(s)
Total download size: 9.6 M
Installed size: 27 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): mysql-5.1.73-3.el6_5.x86_64.rpm | 894 kB 00:00
(2/3): mysql-server-5.1.73-3.el6_5.x86_64.rpm | 8.6 MB 00:00
(3/3): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm | 134 kB 00:00
-----------------------------------------------------------------------
Total 11 MB/s | 9.6 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mysql-5.1.73-3.el6_5.x86_64 1/3
Installing : perl-DBD-MySQL-4.013-3.el6.x86_64 2/3
Installing : mysql-server-5.1.73-3.el6_5.x86_64 3/3
Verifying : perl-DBD-MySQL-4.013-3.el6.x86_64 1/3
Verifying : mysql-server-5.1.73-3.el6_5.x86_64 2/3
Verifying : mysql-5.1.73-3.el6_5.x86_64 3/3
Installed:
mysql-server.x86_64 0:5.1.73-3.el6_5
Dependency Installed:
mysql.x86_64 0:5.1.73-3.el6_5 perl-DBD-MySQL.x86_64 0:4.013-3.el6
Complete!
$
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for azureuser:
Loaded plugins: security
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
openlogic | 1.3 kB 00:00
openlogic/primary | 273 kB 00:00
openlogic 27/27
updates | 3.4 kB 00:00
updates/primary_db | 3.2 MB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.x86_64 0:5.1.73-3.el6_5 will be installed
--> Processing Dependency: mysql = 5.1.73-3.el6_5 for package: mysql-se
rver-5.1.73-3.el6_5.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1
.73-3.el6_5.x86_64
--> Running transaction check
---> Package mysql.x86_64 0:5.1.73-3.el6_5 will be installed
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================
Package Arch Version Repository Size
=======================================================================
Installing:
mysql-server x86_64 5.1.73-3.el6_5 updates 8.6 M
Installing for dependencies:
mysql x86_64 5.1.73-3.el6_5 updates 894 k
perl-DBD-MySQL x86_64 4.013-3.el6 base 134 k
Transaction Summary
=======================================================================
Install 3 Package(s)
Total download size: 9.6 M
Installed size: 27 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): mysql-5.1.73-3.el6_5.x86_64.rpm | 894 kB 00:00
(2/3): mysql-server-5.1.73-3.el6_5.x86_64.rpm | 8.6 MB 00:00
(3/3): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm | 134 kB 00:00
-----------------------------------------------------------------------
Total 11 MB/s | 9.6 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mysql-5.1.73-3.el6_5.x86_64 1/3
Installing : perl-DBD-MySQL-4.013-3.el6.x86_64 2/3
Installing : mysql-server-5.1.73-3.el6_5.x86_64 3/3
Verifying : perl-DBD-MySQL-4.013-3.el6.x86_64 1/3
Verifying : mysql-server-5.1.73-3.el6_5.x86_64 2/3
Verifying : mysql-5.1.73-3.el6_5.x86_64 3/3
Installed:
mysql-server.x86_64 0:5.1.73-3.el6_5
Dependency Installed:
mysql.x86_64 0:5.1.73-3.el6_5 perl-DBD-MySQL.x86_64 0:4.013-3.el6
Complete!
$
/etc/my.cnfを編集し、デフォルトの文字コードを UTF-8 に設定します。
$ sudo vi /etc/my.cnf
[sudo] password for azureuser:
[sudo] password for azureuser:
default-character-setを追記します。
[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
default-character-set=utf8 ←追加
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
default-character-set=utf8 ←追加
[mysql] ←追加
default-character-set=utf8 ←追加
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
default-character-set=utf8 ←追加
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
default-character-set=utf8 ←追加
[mysql] ←追加
default-character-set=utf8 ←追加
MySQLサーバーを起動します。
$ sudo /etc/init.d/mysqld start
Initializing MySQL database: Installing MySQL system tables...
140731 9:42:44 [Warning] '--default-character-set' is deprecated and w
ill be removed in a future release. Please use '--character-set-serve
r' instead.
OK
Filling help tables...
140731 9:42:45 [Warning] '--default-character-set' is deprecated and w
ill be removed in a future release. Please use '--character-set-serve
r' instead.
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 TestAzure 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 ]
Initializing MySQL database: Installing MySQL system tables...
140731 9:42:44 [Warning] '--default-character-set' is deprecated and w
ill be removed in a future release. Please use '--character-set-serve
r' instead.
OK
Filling help tables...
140731 9:42:45 [Warning] '--default-character-set' is deprecated and w
ill be removed in a future release. Please use '--character-set-serve
r' instead.
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 TestAzure 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 ]
Warningが出ています。default-character-setは未来のバージョンでなくなるようなので、character-set-serverを使うようにとのことです。
mysqldとmysqld_safeのdefault-character-setをcharacter-set-serverに変更します。
[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 ←変更
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character-set-server=utf8 ←変更
[mysql]
default-character-set=utf8
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 ←変更
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character-set-server=utf8 ←変更
[mysql]
default-character-set=utf8
自動起動の設定をします。
$ sudo chkconfig mysqld on
[sudo] password for azureuser:
[sudo] password for azureuser:
rootのパスワードを AzMySQL123 に設定します。
$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights rese
rved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input sta
tement.
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=password('AzMySQL123') where user='root
';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights rese
rved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input sta
tement.
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=password('AzMySQL123') where user='root
';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
rootでログインし、匿名ユーザーを削除します。
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> delete from user where user='';
Query OK, 2 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> delete from user where user='';
Query OK, 2 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
以上で設定は完了です。
仮想マシンは使い終わったら必ずダッシュボードからシャットダウンさせましょう。
Copyright (C) 2014 ymlib.com