How to modify the MySQL data file storage location

Source: Internet
Author: User
Tags mkdir net command

MySQL installed on the FreeBSD host when the database files are placed under/var/db/mysql, the default storage location on the Linux host is/var/lib/mysql/.

If you want to replace the storage location of the MySQL data file:

FreeBSD under:

#/usr/local/etc/rc.d/mysql-server Stop (stopping MySQL)
# mkdir/other/db (Create a new data file directory, you can also move directly over)
# mv/var/db/mysql/other/db (move data file)
# ln-s/other/db/mysql/var/db/mysql (set up soft links for data files)
#/usr/local/etc/rc.d/mysql-server start (starting MySQL)


Linux under:

(under the test of Linux, you can not stop the MySQL and direct operation, but if the database is often updated or first stop the good, stop the method here is not introduced!) )

# mkdir/data/database (Create a new data file directory, you can also move directly over)
# mv/var/lib/mysql/data/database/(move data file)
# ln-s/data/database/mysql/var/lib/mysql (set up soft links for data files)

If your operation user is not MySQL, such as the root user operation, it may be that MySQL has no read access to the newly established Data folder, Chown, or Chgrp,chmod!


How to modify in Windows system

1. Query data File storage location


Mysql> Show variables like ' DataDir '
->;
+---------------+-------------------+
| variable_name | Value |
+---------------+-------------------+
| DataDir | d:/mysql5.0/data/|
+---------------+-------------------+
1 row in Set (0.00 sec)

Mysql> Show variables like ' DataDir '
->;
+---------------+-------------------+
| variable_name | Value |
+---------------+-------------------+
| DataDir | d:/mysql5.0/data/|
+---------------+-------------------+
1 row in Set (0.00 sec)

2. Stop MySQL database use NET command to stop service


C:/Documents and Settings/administrator>net stop MySQL

The MySQL service is stopping.

The MySQL service has stopped successfully.

C:/Documents and Settings/administrator>net stop MySQL

The MySQL service is stopping.
The MySQL service has stopped successfully.

Of course, you can also view the MySQL directory of My.ini files

3. Modify the My.ini folder

#Path to the database root
Datadir= "D:/mysql5.0/data"

4. Start service OK


C:/Documents and settings/administrator>net start MySQL
The MySQL service is starting.
The MySQL service has started successfully.

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.