Linux modifies the Mysql database file path _mysql

Source: Internet
Author: User
MySQL change data file storage path feel directly to the/etc/my.cnf in the DataDir to restart the service on the line, but search from the Internet more than n data, most of the changes in the My.cnf DataDir and sock and startup scripts/etc/rc.d/ Init/mysqld in the DataDir, according to the solution provided on the Internet seems not all right, there is no warrior to give a positive statement

In fact, only two things to do: one is MV the socket and data directory. That is, to move it from the original directory to the specified location, and second, to modify the configuration file, if it is started directly with the command below Mysql/bin, Directly change the MY.CNF can be, that is, the directory of Ocket and data to the location you moved to, if you want it on the boot can automatically start services or use service to start, the estimated need to modify/etc/rc.d/init/ The DataDir in the mysqld.

There is one more:

First look at the database in the database of the current data file storage path:
Copy Code code as follows:

Mysql> Show variables like '%dir% ';
+----------------------------+----------------------------+
| variable_name | Value |
+----------------------------+----------------------------+
| Basedir | / |
| Character_sets_dir | /usr/share/mysql/charsets/|
| DataDir | /data/mysql/|
| Innodb_data_home_dir | |
| Innodb_log_arch_dir | |
| Innodb_log_group_home_dir |./|
| innodb_max_dirty_pages_pct | 90 |
| Slave_load_tmpdir | /tmp/|
| Tmpdir | /tmp/|
+----------------------------+----------------------------+

If you think this path is possible, you don't have to change it. If you feel dissatisfied, you can also change.

1:service MySQL Stop

Close Database

2:vi/etc/rc.d/init.d/mysql

3: Change the datadir=/var/lib/mysql here to what you want. It's OK.

4:service MySQL Start

How to change the MySQL data file path

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.