2012年6月4日月曜日

mysqlのインストールと設定

インストール

# yum -y install mysql-server mysql
Loaded plugins: fastestmirror, priorities, security
Loading mirror speeds from cached hostfile
 * epel: ftp.iij.ad.jp
 * ius: archive.linux.duke.edu
 * sl: ftp.riken.jp
 * sl-security: ftp.riken.jp
103 packages excluded due to repository priority protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.x86_64 0:5.1.61-1.el6_2.1 will be installed
---> Package mysql-server.x86_64 0:5.1.61-1.el6_2.1 will be installed
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.61-1.el6_2.1.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.61-1.el6_2.1.x86_64
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.61-1.el6_2.1.x86_64
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================
 Package                  Arch             Version                     Repository             Size
===================================================================================================
Installing:
 mysql                    x86_64           5.1.61-1.el6_2.1            sl-security           881 k
 mysql-server             x86_64           5.1.61-1.el6_2.1            sl-security           8.1 M
Installing for dependencies:
 perl-DBD-MySQL           x86_64           4.013-3.el6                 sl                    133 k
 perl-DBI                 x86_64           1.609-4.el6                 sl                    704 k

Transaction Summary
===================================================================================================
Install       4 Package(s)

Total download size: 9.8 M
Installed size: 28 M
Downloading Packages:
(1/4): mysql-5.1.61-1.el6_2.1.x86_64.rpm                                    | 881 kB     00:00     
(2/4): mysql-server-5.1.61-1.el6_2.1.x86_64.rpm                             | 8.1 MB     00:02     
(3/4): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm                                | 133 kB     00:00     
(4/4): perl-DBI-1.609-4.el6.x86_64.rpm                                      | 704 kB     00:00     
---------------------------------------------------------------------------------------------------
Total                                                              3.2 MB/s | 9.8 MB     00:03     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : perl-DBI-1.609-4.el6.x86_64                                                     1/4 
  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64                                               2/4 
  Installing : mysql-5.1.61-1.el6_2.1.x86_64                                                   3/4 
  Installing : mysql-server-5.1.61-1.el6_2.1.x86_64                                            4/4 

Installed:
  mysql.x86_64 0:5.1.61-1.el6_2.1              mysql-server.x86_64 0:5.1.61-1.el6_2.1             

Dependency Installed:
  perl-DBD-MySQL.x86_64 0:4.013-3.el6                 perl-DBI.x86_64 0:1.609-4.el6                

Complete!

起動設定

自動起動の設定。
# chkconfig mysqld on

初期設定

/etc/my.cnfファイルを編集。
[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
skip-name-resolve
skip-innodb
default-storage-engine=MyISAM

key_buffer = 128M
max_allowed_packet = 16M
join_buffer = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 768K
thread_stack = 192K
thread_cache_size = 512
max_connections = 300
table_cache = 1024
tmp_table_size = 16M
thread_concurrency = 4
query_cache_limit = 4M
query_cache_size = 64M
query_cache_min_res_unit= 4k
query_cache_type = 1

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[mysql]
default-character-set = utf8

[isamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M

[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M
mysqldを起動。
# service mysqld start
MySQL データベースを初期化中:  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 49.212.129.72 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  ]
mysqld を起動中:                                           [  OK  ]
mysql_secure_installationを実行し、セキュリティ設定を行う。
# /usr/bin/mysql_secure_installation

NOTE: 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): 
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] 
New password: 
Re-enter new password: 
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] 
 ... 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] 
 ... 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] 
 - 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] 
 ... 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!

0 件のコメント:

コメントを投稿