66
69

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MySQLのデータディレクトリを移動する

Last updated at Posted at 2013-09-11

##■/var/lib/mysqlから/test/mysqlに移動する

/etc/init.d/mysql stop

●mysqlの停止

cp my.cnf my.cnf.back

●my.cnfのバックアップ

vi my.cnf

●my.cnfの編集

socket = /test/mysql/mysql.sock
log-slow-queries = /test/mysql
log-bin = /test/mysql/mysql-bin
innodb_data_home_dir = /test/mysql/
innodb_log_group_home_dir = /test/mysql/

●ログやらデータディレクトリやらの指定を新ディレクトリに変更する

vi /etc/init.d/mysql

●起動ファイルを編集する

datadir=/var/lib/mysql  →  datadir=/test/mysql

●datadirを変更

cp -pR /var/lib/mysql/* /test/mysql

●ディレクトリお引越し

/etc/init.d/mysql start

●mysqlを起動

mysqladmin variables -u root -p | grep "/var/lib/mysql"

●旧ディレクトリに向いている設定が無いか確認
無ければ/var/lib/mysqlを削除して終了

#■追記
下記のエラーが出る場合はSELinuxを無効にする

Starting MySQL. ERROR! The server quit without updating PID file

●SELinux無効化

setenforce 0

●恒久的にSELinuxを無効化する

vim /etc/sysconfig/selinux
SELINUX=disabled
66
69
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
66
69

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?