Change datadir mysql

GIT – is a widely used and fast SQL database server.How to change datadir , backup database , optimize . It is a client/server implementation that consists of a server daemon (mysqld) and many different client programs/libraries.

What is Mysql Data Directory?

Mysql data directory is important part where all the mysql databases storage location.By default MySQL data default directory located in /var/lib/mysql. If you are running out of space in /var partition you need to move this to some other location.

Note: This is only for advanced users and before moving default directory make a backup of your mysal databases.

Step 1. Backup your database!

Step 2. Shutdown mysql

service mysqld stop

Step 3. Create a new data directory on /mnt and change

mkdir /data/mysql

Step 4. Change ownership of that directory to the same owner of your rails app

chown mysql:mysql -R /data/mysql

Step 5. Modify the mysql config file

whereis my.cnf

=> /etc/my.cnf

vi /etc/my.cnf

Which will look like this:






Noticed I changed the very first line to point to /data/mysql.

Step 6. Move your databases to /data/mysql

# mv /var/lib/mysql/ /data/mysql

Step 7. Restart mysql

service mysqld start

Thảo luận bài viết tại forum :

Bài viết này nằm trong dự án  website :, forum hổ trợ , xem thêm tại link
Print Friendly, PDF & Email



Bài viết liên quan

1 Trackback / Pingback

  1. Hướng dẫn cài đặt & sử dụng Ubuntu / Linux Toàn tập | Nguyễn Bá Mãi

Để lại lời nhắn