linux - MySQL: Can I create a database with command `cp` on centos? -
creating database mysql command this:
create database new_york; use new_york; create table authors(id int,name varchar(10),gender varchar(5)); create table articles(id int,title varchar(255),content text);
above created database named new_york
, , has 2 tables authors
, articles
.
now need database named los_angeles
,it has same tables new_york
,and each table has same structure.
can repeat sentences above create it.
create database los_angeles; use los_angeles; create table authors(id int,name varchar(10),gender varchar(5)); create table articles(id int,title varchar(255),content text);
but can create using command cp
of linux? this:
cd /var/lib/mysql cp -a new_york los_angeles
now in /var/lib/mysql
,there folder los_angeles
,and there table files in folder.
so ok create databases command cp
if have same tables?
no can not create database using cp command. easiest way
1- dump new_york database without data.
mysqldump -u${username} -p --no-data new_york > new_york.sql
2- create los_angeles, , import new_york database dump.
create database los_angeles; use los_angeles; source new_york.sql;
hope helps
Comments
Post a Comment