MySQL Local Data Directory Migration

Source: Internet
Author: User
Tags mysql free

Requirements: MySQL's original directory is out of space, need to migrate MySQL directory in this machine

Mkdir-p/home/mysql3306/data
Mkdir-p/home/mysql3306/log
Mkdir-p/home/mysql3306/run/mysqld

Original directory:/var/lib/mysql
Migration Destination Directory:/home/mysql3306/data
Cp-r/var/lib/mysql/*/home/mysql3306/data/

Chown-r mysql.mysql/home/mysql3306

————————————————————————————
Vim/etc/my.cnf
#join_buffer_size = 128M
#sort_buffer_size = 2M
#read_rnd_buffer_size = 2M
#datadir =/var/lib/mysql
Datadir=/home/mysql3306/data
#socket =/var/lib/mysql/mysql.sock
Socket=/home/mysql3306/data/mysql.sock
Lower_case_table_names=1
#Disabling Symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0
max_connections=1000
max_connect_errors=300
#Recommended in standard MySQL setup
Sql_mode=no_engine_substitution,strict_trans_tables
[Mysqld_safe]
#log-error=/var/log/mysqld.log
Log-error=/home/mysql3306/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid
Pid-file=/home/mysql3306/run/mysqld/mysqld.pid
[MySQL] # # Here Add 2 lines, avoid mysql-uroot-p when the report can not find sock file
Socket=/home/mysql3306/data/mysql.sock
WQ: Save here
————————————————————————————————
VIM/ETC/INIT.D/MYSQLD # # Modify the following variables
Get_mysql_option mysqld datadir "/home/mysql3306/data"
#get_mysql_option mysqld datadir "/var/lib/mysql"
Datadir= "$result"
Get_mysql_option mysqld Socket "$datadir/mysql.sock"
Socketfile= "$result"
Get_mysql_option mysqld_safe log-error "/home/mysql3306/log/mysqld.log"
#get_mysql_option mysqld_safe log-error "/var/log/mysqld.log"
Errlogfile= "$result"
Get_mysql_option mysqld_safe pid-file "/home/mysql3306/run/mysqld/mysqld.pid"
#get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid"
——————————————————————————————————

/etc/init.d/mysqld stop
/etc/init.d/mysqld start
Mysql-uroot-p Verify that the data is
DESC table name;
Error sqlstate[hy000]: General error:1030 Got error * from storage engine
This is because the/tmp directory has no space, rm-rf/var/lib/mysql free space, delete other files are also OK, as long as you can free up some space.

Complete

MySQL Local Data Directory Migration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.