Copy Mysql Database Database Structure

I am using MySql 5.1 database.

I created a project database. (Template Database)

and you want to create a copy of the same database from the application every time a user creates a new project.

How can I copy and create a new database of the same structure.

What is a team for this?

Thanks for the help.

+3
source share
3 answers

If you want to copy the structure of the table, etc. from one database to another, you can use this single bash line:

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

A new database must exist already. The -d flag in mysqldump prevents data from being copied.

+18
source

Dump the database with the -d option.

, "create database new-database-name, new-data-base-name;", sql script.

+1

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 this table.

-1
source

Source: https://habr.com/ru/post/1706792/


All Articles