我已经使用 MySQL Workbench 创建了一个 MySQL 数据库。它有大约20张 table 。我不知道如何在数据库上运行脚本。
基本上,我想制作一个数据库创建脚本,它允许我在任何其他 MySQL 服务器上创建我的数据库。
最佳答案
create database mydatabase;
grant all on mydatabase.* to 'myuser'@'%' identified by 'mypasswd';
create table mytable (
id int not null auto_increment,
myfield varchar(255) not null default ''
);
等...
将其放入名为 mydbcreate.sql 的文件中并运行(从命令行)
mysql -u <myuser> -p < mydbcreate.sql
关于mysql - 如何在 mysql 数据库上/中运行脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2457198/