Jump to Navigation

203 - Change the MySQL's DATADIR

The default MySQL's datadir is placed in the /var/lib/mysql.
if you plan on using MySQL tables to store a lot of data and your /var partition might be a small space, it causes a space problem.
You had better move the MySQL's datadir to another space.

1. Stop your mysql server

# service mysqld stop  (or /etc/init.d/mysqld stop)

2. Create the new directories

3. chown the directory to the mysql:mysql user

4. Copy the all files from the old datadir to the new location.

5. The files named ib_arch_log_xxxxxxx, ib_logfilex etc. are not copied to the new location.

6. Make changes in the my.cnf to point the new datadir.

# vi /etc/my.cnf

7. Restart the MySQL database.

# service mysqld start  (or /etc/init.d/mysqld start)

8. Delete old files after backups.

 



Main menu 2

Story | by Dr. Radut