ユーザ用ツール

サイト用ツール


サイドバー

Index

はじめてのおつかい






DokuWiki整形記法


PlayGround



os:centos:mysql

MySQL

Install

標準は

# yum info mysql.x86_64
Available Packages
Name        : mysql
Arch        : x86_64
Version     : 5.1.69
Release     : 1.el6_4
Size        : 907 k
Repo        : updates
Summary     : MySQL client programs and shared libraries
URL         : http://www.mysql.com
License     : GPLv2 with exceptions
Description : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
            : client/server implementation consisting of a server daemon (mysqld)
            : and many different client programs and libraries. The base package
            : contains the standard MySQL client programs and generic MySQL files.

と言うわけで古すぎるので、新しめの5.5を入れる
remiに新しいのが置かれるようになったので

# yum install --enablerepo=remi mysql
# yum install http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.5/MySQL-client-5.5.31-2.el6.x86_64.rpm \
              http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.5/MySQL-shared-compat-5.5.31-2.el6.x86_64.rpm \
              http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.5/MySQL-server-5.5.31-2.el6.x86_64.rpm \
              http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.5/MySQL-devel-5.5.31-2.el6.x86_64.rpm

shared-compatを入れた後ならsharedも入るので入れる

# yum install http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.5/MySQL-shared-5.5.31-2.el6.x86_64.rpm 

起動

# service mysql start ←mysqldからmysqlに変更されてる...

自動起動をONにする

# chkconfig mysql on

設定

utf-8をDefaultにする。(/etc/my.cnf)

[mysqld]
...
#default-character-set = utf8 ←5.5で廃止されてます
character_set_server = utf8

[mysql]
default-character-set = utf8

[mysqldump]
default-character-set = utf8

rootパスワードの設定

初期ではrootパスワードが設定されていないので、とっとと設定します。1)2)

# mysql -u root
mysql> SET PASSWORD FOR root@localhost = PASSWORD('*********');

my.cnfサンプル

/usr/share/mysql にある3)

それぞれ以下の様な内容

ファイル名内容
my-small.cnf64MB以下のメモリを搭載したPC
my-medium.cnf128MB以下のメモリを搭載したPC
my-large.cnf512MB以下のメモリを搭載したPC
my-huge.cnf1GB~2GB以下のメモリを搭載したPC
my-innodb-heavy-4G.cnf4GBのメモリとInnoDBで作成されたデータベースによって構築されたPC

外部からの接続を許可する

データディレクトリの変更

ふつうは

cp -rpf origin-path new-path

として、/etc/my.cnfのdatapathなんかを変更すればOKのはず

だが、

The server quit without updating PID file /new-path/xxxxxxxxx.pid).

などと言って、立ち上がらなかったので

mysql_install_db --datadir=/new-path/mysql --user=mysql

してから

service mysql start
1)
5.6ではデフォルトパスワードが設定されて、/root/.mysql_secret に置かれてるらしい
2)
なお、mysql.user.password_expiredの値(5.6の新機能)が'Y'になっているのでパスワードを変更しないとあっちこっちで'You must SET PASSWORD before executing this statement'と怒られます
3)
5.6で廃止された?
os/centos/mysql.txt · 最終更新: 2021/05/11 16:07 by 40.77.167.76