No announcement yet.

How To Change The Path of MySQL Databases?


Unconfigured Ad Widget

  • Filter
  • Time
  • Show
Clear All
new posts

  • How To Change The Path of MySQL Databases?

    WordPress Hosting on SSD Servers
    By default, MySQL location is /var/lib/mysql folder. But, what if your /var directory has less space to store databases?. In such case, you can change the default MySQL location to a new desired path. Below are the exact steps:

    Step 1:

    Stop MySQL service using below command:

    service mysqld stop

    Step 2:

    Create a new desired directory at where you wish to start storing mysql databases. For example, you create /usr/database directory using below command.

    mkdir /user/database

    Step 3:
    Copy existing databases (/var/lib/mysql) to new location (/usr/database):

    cp -€“R /var/lib/mysql /usr/database

    Step 4:

    Locate MySQL configuration file (usually located at /etc/my.cnf) and change default path of mysql databases:

    datadir = /var/lib/mysql
    Change it to
    datadir = /usr/database

    Step 5:

    Start mysql service using below command:

    Service mysqld start
    Last edited by admin; 07-30-2015, 06:24 AM.

Sign up for a News Letter Click here to sign up