复制Mysql数据库的数据库结构

您所在的位置:网站首页 mysql复制命令 复制Mysql数据库的数据库结构

复制Mysql数据库的数据库结构

2023-04-14 12:12| 来源: 网络整理| 查看: 265

百度翻译此文   有道翻译此文 问题描述

I am using MySql 5.1 Database.

I have created a Project database. (Template Database)

and want to Create a copy of the same database from the Application, every time, User Creates A new Project.

How can I copy and Create a New Database of same structure?

What is the Command to do so?

推荐答案

If you only want to copy the table structure etc. from one db to the other you can use this single bash line:

mysqldump -u user -ppass -d olddb | mysql -u user -ppass -Dnewdb

The new database must exist already. The -d flag in the mysqldump command prevents copying of data.

其他推荐答案

Dump the database with the -d option.

To create a new copy, do a "create database new-database-name; use new-data-base-name;", then run the dump file as a sql script.

其他推荐答案

Check out the SHOW CREATE TABLE command: https://dev.mysql.com/doc/refman/5.0/en/show-create-table.html It will return the create command used to create the given table.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3