Mysql directly changes the storage path of data files to/etc/my. in cnf, modify the datadir and restart the service. However, I searched for more information from the Internet, most of which were changed to my. in cnf, datadir, sock, and startup script/etc/rc. the datadir in d/init/mysqld does not seem to work according to the solutions provided on the Internet. Is there a saying that hero gives me a positive explanation?
In fact, we only need to do two things: one is the mv socket and data directory. That is to say, it is to move it from the original directory to the specified location. Second, it is to modify the configuration file. If it is directly started using the command below mysql/bin, it is directly changed to my. cnf is enough, that is, you can change the ocket and data directory to your location. If you want it to automatically start the service or use the service when it is started, it is estimated that/etc/rc needs to be modified. d/init/datadir in mysqld.
There is also one:
First, let's take a look at the storage path of the current data file in the database:
Copy codeThe Code is 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 okay, you don't have 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
How to change the MySQL Data File Path