How can I change the MySQL data file path? Many people may have such questions. The following describes how to change the path of the MySQL data file. Before that,
Let's take a look at the path of the current MySQL Data File in the database:
- 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 the MySQL data file path is correct, you do not need to modify it. If you are not satisfied, you can modify it.
1: service mysql stop
Close Database
2: vi/etc/rc. d/init. d/mysql
3: Change datadir =/var/lib/mysql to what you want. OK.
4: service mysql start
Modify Table Structure in MySQL -- add and delete Fields
Seven common MySQL command lines
Use the MySQL command line to change the password
Optimize MySQL statement instances through Indexes
Cancel MySQL user permissions