写了一个SQL文件inter.sql
code:drop database if exsits inter;
create database inter;
#下面建表这就不写了.....
我写了一个批处理文件create.bat,bat文件内容如下:
mysql -h localhost -u root -p inter < inter.sql双击create.bat文件执行时报错,Unknown database 'inter'请问这样写法有错误吗?我把
drop database if exsits inter;
create database inter;
代码  在MYSQL用可视化界面工具执行没问题啊。

解决方案 »

  1.   

    mysql -h localhost -u root -p   < inter.sql
      

  2.   

    你出错的根源在于-p 后边指定了inter(数据库名)
    mysql -h localhost -u root -p inter < inter.sql
    你如果想指定密码:
    直接:mysql -h localhost -u root -p<passwd> < inter.sql
    把passwd连在-p后边就行了。
      

  3.   

    按你说的去掉  "<" 前面的inter报下面的错误
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'exsits interweb' at line 1 
      

  4.   

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'exsits inter' at line 1
      

  5.   

    drop database if exists inter;
    create database inter;mysql -h localhost -uroot -p< inter.sql
      

  6.   

    select schema_name from information_schema.schemata;
      

  7.   

    DROP DATABASE IF EXISTS  inter