MySQL Mobile database location

Source: Internet
Author: User

http://zlyang.blog.51cto.com/1196234/1726029

Requirements: MySQL database file original location:/var/lib/mysql to:/data/mysql

1. First create a folder named: MySQL in the/data directory:
# Mkdir/data/mysql
# Chown-r Mysql:mysql/data/mysql
# Chmod-r 755/data/mysql


2. Stop all MySQL services:
# Service HTTPD Stop
# Service Mysqld Stop

# Netstat-an |grep 3306//See if the MySQL service has stopped


3, copy the files under the/var/lib/mysql to the/data/directory:
# Mv/var/lib/mysql/data


4. Modify the configuration file:
# VI/ETC/MY.CNF

[Mysqld]
#datadir =/var/lib/mysql//original path
Datadir=/data/mysql//modified path

#socket =/var/lib/mysql/mysql.sock//Original sock path
Socket=/data/mysql/mysql.sock//Modified sock path


5. Modify the startup script:
# Vim/etc/init.d/mysqld

#get_mysql_option mysqld DataDir "/var/lib/mysql"//Original sock path
Get_mysql_option mysqld DataDir "/data/mysql"//Modified sock path


6. Start the MySQL service:
# service Mysqld Start
# service httpd Start
# Mysql-uroot-p//test can log in normally;

Error 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock '///If the error occurs, do the following:

# Mkdir/var/lib/mysql
# ln-s/data/mysql/mysql.sock/var/lib/mysql/mysql.sock


7, after the implementation of the above operation, the migration of database files has been completed.

MySQL Mobile database location

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.