Mysql create database in user folder

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

Thanks.

+7
source share
4 answers
  • Create a folder on the target drive for the database that you want to create.

  • make mlink with the name of the database you need, if db name is db1:

 mklink /d db1 g:\db1data 
  • on win7 you need to run the cmd command as admin - right-click to start as administrator.

  • g: \ db1data must exist before running the mlink command and stopping mysql, before you do this, restart to see the new database.

  • just used this to make db on a RAM disk. Plan to copy it to a disk with a "normal" db before turning it off!

Link http://dev.mysql.com/doc/refman/5.6/en/symbolic-links.html

Used imdisk tool with command:

imdisk -a -t vm -mg: -s 2g

First create a RAM disk.

+3
source

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

MySQL uses the folder specified in the file my.cnf to host your files - Find option datadir file .cnf .

Link to documents for datadir

+2
source

On Linux, this can be painless using simple symbolic links:

 1) first check in my.cnf [/etc/mysql/my.cnf] for database files destination. 2) let 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. 
+1
source

InnoDB tables could be placed in a different directory if the file on the table used MySQL 5.6 Manual

0
source

Source: https://habr.com/ru/post/910584/


All Articles