Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create database in custom folder

Tags:

mysql

Is it possible to create database in custom folder? Like: mysql> create database test FOLDER='/home/username/db_folder/'?

like image 730
ted Avatar asked Mar 13 '12 11:03

ted


Video Answer


2 Answers

In Linux environment it can be painless using simple symbolic links:

  1. First check in my.cnf [/etc/mysql/my.cnf] for database files destination.
  2. Let's say that destination is in folder /var/lib/mysql/ and yours database name is "abccompany"
  3. Stop mysql database
  4. Move folder [var/lib/mysql/abccompany] to new destination (let say "/diskY")
  5. Make symbolic link:
    ln  -s  /diskY/abccompany   abccompany
    
  6. Start mysql database and everything should work just fine.
like image 182
Amit Vujic Avatar answered Oct 19 '22 19:10

Amit Vujic


No its not possible .. there is no FOLDER switch for the create database command : http://dev.mysql.com/doc/refman/5.0/en/create-database.html

MySQL uses the folder specified in the my.cnf file for the placement of its files - look for the datadir option in the .cnf file.

Link to the docs for datadir

like image 40
Manse Avatar answered Oct 19 '22 18:10

Manse