I am using MySQL on Ubuntu machine.
I need to physically move around the database files under /var/lib/mysql/
(this is where all the databases directories are located).
Say I have two databases, db_1 and db_2, so I can see two directories(db_1/
and db_2/
) under the path /var/lib/mysql/
. Under each of these two database directory, there are many .frm
.MYD
.MYI
files which holds all the tables' informations of the database.
For example, under db_1/
directory there are following files:
/var/lib/mysql/db_1# ls cars.frm cars.MYD cars.MYI customers.frm customers.MYD customers.MYI departments.frm departments.MYD departments.MYI ...
which holds cars, customers, departments tables' info.
I need a shell script to do the following simple task:
make a new direcotry named
db_1_temp
under/var/lib/mysql/
move files related with cars and customers tables in
db_1
directory todb_1_temp
direcotrymove files in
db_2
directory todb_1
direcotry
NOTE, user need root privilege to access /var/lib/mysql/
I need these things in a .sh file so I can run it in another application.
Sorry that I do not know shell script, but need this thing. Appreciate if anyone can give a help, this shell script should not be hard I think. I try to extract some time to learn shell, as now I am quite busy with other software development. Thank you!