How to change default MySQL directory

How to change default MySQL directory

Originally it will be located at /var/lib/mysql

Say you want to change it to /home/myApps/mysql

First if the mysql is running stop it: sudo /etc/init.d/mysql stop
and stop the server too: sudo/etc/init.d/apache2 stop

Go to /etc/mysql/my.cnf and edit:
datadir = /var/lib/mysql to datadir = /home/myApps/mysql

Copy files from existing path to the new path
cp -R /var/lib/mysql* /home/myApp/mysql

Grant ownership to new directory for mysql

sudo chown -R mysql:mysql /home/myApp/mysql

then start up your server and mysql – voila.

install composer and make it globally accessible

Mac Numbers document to Excel

Configuring PHP + MySQL + Apache on Amazon EC2 Step by Step

Access MySQL from Host being on Vagrant

Setting new Vagrant machine for PHP-Mysql development

error duplicate entry for key when creating new unique key mysql

  1. Rahul


    Great. Nice article thanks for sharing.

    1. gullele

      Thanks Rahul

  2. DBAWork

    Nice blog, thank you for sharing

Leave a Reply

Your email address will not be published. Required fields are marked *