Articles

Linux Mandrake/Mandriva change mysql datadir, mysql database location path

Linux Mandriva change mysql datadir / database location dir in 5 minutes

Move mysql database to other path or disk


  • Open the terminal
  • Stop MySQL with the command
    /etc/init.d/mysqld stop

Way 1

  • Move existing data directory (which is located in /var/lib/mysql) to new dir /usr/new_datadir using the command

    mv /var/lib/mysql /usr/new_datadir
  • Create symlink from new dir to old one

    ln -s /usr/new_datadir /var/lib/mysql

Way 2

  • Move existing data directory (which is located in /var/lib/mysql) to new dir /usr/new_datadir using the command

    mv /var/lib/mysql /usr/new_datadir
  • Edit the MySQL configuration file with the command

    vim /etc/mysql/my.cnf
  • Find the entry for datadir, change the path to the new data directory.
Final
  • Restart MySQL with the command

    /etc/init.d/mysqld restart
  • MySQL should now start without any errors, have fun! In my case i have Mandriva 2008 Spring Edition, and all going perfectly with moving and symlink.