I hope this article will be helpful to change MySQL default data directory to new location. If you are facing any issue during MySQL service startup check its log file /var/log/mysqld.log for error. Socket=/mysql_data/var/lib/mysql/mysql.sock Start MySQL Service # service mysqld start Open the MySQL /etc/my.cnf default configurations and modify datadir and socket variable like below. ![]() # chown -R mysql:mysql /mysql_data Update my.cnf Default Configuration File Follow the below command to change ownership. If you have copied MySQL data directory instead of move, you will need to change the ownership on new directory. Now I am going to move MySQL database from / partition to /mysq_data partition. In my case there are no much space in my root partition that’s why I have added another hard drive and I have /mysql_data partiton on /dev/sdb1 disk which has lot of space. # mysqldump -u root -ppassword -all-databases > /opt/backup/all-database-bkp.sql Change MySQL Data Directory to New Location Or, you can also use mysqldump to take MySQL database backup. For backup copy this directory to safe location. # /etc/init.d/mysqld stop Take Current MySQL Database BackupĪfter stopping the MySQL service, I will suggest take a backup of your current MySQL database.You can find the current MySQL database under /var/lib/mysql directory. Stop MySQL Serviceīefore doing anything make sure MySQL service is stopped follow the below command to stop MySQL service # service mysqld stop In this tutorial I am going to explain how we can change MySQL default data directory to new location.įollow the below steps to change MySQL default data directory. But for larger database I will suggest to change the default data directory of MySQL to different locations or you can also use separate hard disk for database. If your database is small this might be OK because it does not take much space. When we install MySQL on Linux the default MySQL database created under /var/lib/mysql directory.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |