[英]Create and restore Database using Batch file in Mysql and Windows XP
I am working in WindowsXP . 我正在WindowsXP中工作。 My need is to create a database and restore that
我需要创建一个数据库并将其还原
database with data.sql file using batch script . 使用批处理脚本的data.sql文件的数据库。 This is needed while user configures the project .
用户配置项目时需要这样做。 I tried the following method but it doesn't work for me.
我尝试了以下方法,但对我不起作用。
// createdb.bat
// Password is empty
@echo off
mysql -u root -p < mysql.sql
//mysql.sql
CREATE DATABASE newdb ;
And i have both files in my Desktop . 而且我的桌面上都有两个文件。 Any help please ?
有什么帮助吗?
Thanks for every one to reply my question . 谢谢大家回答我的问题。 As Fuzzy Button said , that was a path issue .
正如Fuzzy Button所说的,这是一个路径问题。 I have to set the path to xps.sql file .
我必须将路径设置为xps.sql文件。 I have just created the createdb.bat with this code it is working well .
我刚刚用此代码创建了createdb.bat,它运行良好。
@echo off
set root=C:\Documents and Settings\Administrator
cd %root%
mysql -u root -e "CREATE DATABASE IF NOT EXISTS xps";
mysql -u root xps < xps.sql
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.