copy database structure without data in mysql (with empty tables)(在mysql中复制没有数据的数据库结构(带有空表))
问题描述
有没有办法在MySQL中复制没有数据的数据库结构,所以新数据库将与复制时相同,但带有空表.
Is there any way to copy database structure without data in MySQL, so the new database will be the same as it is copied from, but with empty tables.
在得到一些建议后,我尝试了该命令,但出现语法错误,我的 username = root 和 password = nothing.我猜是默认的.我正在尝试以下命令,
After getting some suggestions I tried the command, but I am getting syntax error, my username = root and password = nothing. I guess the default one. I am trying following command,
mysqldump -u root -p -d xyz_db | mysql -u root -p -Dnew_db
我在命令中遗漏或放错了什么?
what I am missing or misplacing in command?
推荐答案
mysqldump -u user -ppass -d olddb | mysql -u user -ppass -D newdb
新数据库必须已经存在.mysqldump 命令中的 -d 标志防止复制数据.
The new database must already exist. The -d flag in the mysqldump command prevents copying of data.
-p 标志和密码之间没有空格.
There's no space between the flag -p and the password.
这篇关于在mysql中复制没有数据的数据库结构(带有空表)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在mysql中复制没有数据的数据库结构(带有空表)
基础教程推荐
- 在 SQL 中连接多个表 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 无法解决整理冲突 2021-01-01
