0

how to change mysql location path

By default mysql will be stored in /var/lib/mysql. is it possible to change the location...???

MySQL (My- Structured Query Language) Add a comment
liam
asked Mar 29 2017

Answer

0
  1. Stop MySQL using the following command:

    sudo /etc/init.d/mysql stop

  2. Copy the existing data directory (default located in /var/lib/mysql) using the following command:

    sudo cp -R -p /var/lib/mysql /newpath

  3. edit the MySQL configuration file with the following command:

    sudo gedit /etc/mysql/my.cnf # or perhaps /etc/mysql/mysql.conf.d/mysqld.cnf

  4. Look for the entry for datadir, and change the path (which should be /var/lib/mysql) to the new data directory.

    In the terminal, enter the command:

    sudo gedit /etc/apparmor.d/usr.sbin.mysqld

  5. Look for lines beginning with /var/lib/mysql. Change /var/lib/mysql in the lines with the new path.

    Save and close the file.

  6. Restart the AppArmor profiles with the command:

    sudo /etc/init.d/apparmor reload

  7. Restart MySQL with the command:

    sudo /etc/init.d/mysql restart

  8. Now login to MySQL and you can access the same databases you had before.

Add a comment
linuxhelp
asked Jan 14 2019
edited Jan 14 2019
Post your Answer