$ sudo yum -y install mysql mysql-server mysql-devel mysql-lib
$ sudo /sbin/chkconfig --level 35 mysqld on $ /sbin/chkconfig --list | grep mysql mysqld 0:off 1:off 2:off 3:on 4:off 5:on 6:off
# cd /etc # cp my.cnf my.cnf.original # cp /usr/share/mysql/my-medium.cnf my.cnf
ひな形を元に my.cnf を作る。InnoDB を有効化して文字コードを UTF-8 にする。
= の両側にスペースを入れること!!!
# diff -u /usr/share/mysql/my-medium.cnf /etc/my.cnf --- /usr/share/mysql/my-medium.cnf 2010-06-05 06:55:40.000000000 +0900 +++ /etc/my.cnf 2010-07-27 01:24:47.974290206 +0900 @@ -25,8 +25,9 @@ # The MySQL server [mysqld] port = 3306 +datadir = /var/lib/mysql/ socket = /var/lib/mysql/mysql.sock -skip-locking +skip-external-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 @@ -116,18 +117,23 @@ #log-update = /path-to-dedicated-directory/hostname # Uncomment the following if you are using InnoDB tables -#innodb_data_home_dir = /var/lib/mysql/ -#innodb_data_file_path = ibdata1:10M:autoextend -#innodb_log_group_home_dir = /var/lib/mysql/ +innodb_data_home_dir = /var/lib/mysql/ +innodb_data_file_path = ibdata1:10M:autoextend +innodb_log_group_home_dir = /var/lib/mysql/ # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high -#innodb_buffer_pool_size = 16M -#innodb_additional_mem_pool_size = 2M +innodb_buffer_pool_size = 16M +innodb_additional_mem_pool_size = 2M # Set .._log_file_size to 25 % of buffer pool size -#innodb_log_file_size = 5M -#innodb_log_buffer_size = 8M -#innodb_flush_log_at_trx_commit = 1 -#innodb_lock_wait_timeout = 50 +innodb_log_file_size = 5M +innodb_log_buffer_size = 8M +innodb_flush_log_at_trx_commit = 1 +innodb_lock_wait_timeout = 50 + +character-set-server = utf8 +character-sets-dir = /usr/share/mysql/japanese +default-table-type = InnoDB +skip-character-set-client-handshake [mysqldump] quick
何か知らんが、yum でインストールされるのは消して、作り直すのがよさげ
# rm -rf /var/lib/mysql/ # cd /usr/bin # mysql_install_db --datadir=/var/lib/mysql --user=mysql --group=mysql
# /etc/init.d/mysqld start mysqld を起動中: [ OK ]
簡単にできたようだけどここまで来るのは結構大変。
# /usr/bin/mysqladmin -u root password '**********' # mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.1.47-log Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.00 sec) mysql> quit Bye
$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8081 Server version: 5.1.55-log Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database geoping; Query OK, 1 row affected (0.19 sec) mysql> grant all privileges on geoping.* to geopinguser@"192.168.1.%" identified by '**********'; Query OK, 0 rows affected (0.15 sec) mysql> grant all privileges on geoping.* to geopinguser@localhost identified by '**********'; Query OK, 0 rows affected (0.15 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | cacti | | geoping | | mysql | | test | +--------------------+ 5 rows in set (0.41 sec) mysql> use mysql; Database changed mysql> select host,user from user; +----------------+-------------+ | host | user | +----------------+-------------+ | 127.0.0.1 | root | | 192.168.1.% | geopinguser | | localhost | geopinguser | | localhost | cactiuser | | localhost | root | | orange.homelan | root | +----------------+-------------+ 5 rows in set (0.00 sec) mysql> exit bye
$ mysql -u geopinguser -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8099 Server version: 5.1.55-log Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | geoping | | test | +--------------------+ 3 rows in set (0.00 sec)
$ sudo /usr/bin/system-config-firewall
[~]$ mysql5 -h 192.168.1.2 -u geopinguser -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8132 Server version: 5.1.55-log Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>LAN 内の他のマシンからもログインできた。ポートが 3306 以外のときは、"--port=3306"