简体   繁体   English

在命令行中上传.sql文件时出现语法错误

[英]Syntax error uploading a .sql file in the Command Line

In the Command Line I created a database with: 在命令行中,我使用以下命令创建了一个数据库:

create database mysql;

but when i try to upload a database file with the command: 但是当我尝试使用以下命令上传数据库文件时:

mysql -u root -p  database < dbdump.sql;

i receive a syntax error and i don't understand where i'm wrong 我收到语法错误,但我不明白我在哪里错

ERROR 1064 (42000): 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 'mysql
 -u root -p  database < dbdump.sql' at line 1
  1. confirm you're running the command from a shell and not from mysql. 确认您是从外壳而不是从mysql运行命令。
  2. I recall needing to be in mysql.exe directory when running such commands 我记得运行这样的命令时需要在mysql.exe目录中
  3. remove the spaces around <. 删除<周围的空格。 Ie, write mysql -u root -p database<dbdump.sql 即写mysql -u root -p database<dbdump.sql

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM