你如何使用mysql创建一个抛弃数据库?

时间:2016-07-28 13:00:47

标签: mysql

我正在寻找相当于:

pg_ctl init -D ~/throw-away-database
pg_ctl start -D ~/throw-away-database
……… work work ………
pg_ctl stop -D ~/throw-away-database
rm -rf ~/throw-away-database
MySQL社区服务器5.7.4中的

2 个答案:

答案 0 :(得分:0)

怎么样

create schema my_throw_away001; -- creates a database synonym schema
use my_throw_away001; -- set this as the current to use

-- Do stuff like

create table myTable
(  id int auto_increment primary key,
   thing varchar(100) not null
);

insert myTable(thing) values ('frog'),('cat');

select * from myTable;

-- Cleanup:

drop schema my_throw_away001; -- drops database, poof gone

答案 1 :(得分:0)

mysql_install_db --datadir=/tmp/foo
mysqld_safe --datadir=/tmp/foo --socket=/tmp/foo/mysql.sock
mysql -S /tmp/foo/mysql.sock -u root -p
set password = password('xxxxxxxxxxxxxxxx');
……… work work ………
killall mysqld
rm -rf /tmp/foo