【问题标题】:mysql import is not working [closed]mysql导入不起作用[关闭]
【发布时间】:2012-02-22 10:26:16
【问题描述】:

我想将数据导入mysql,但出现以下错误。

error 1064 :parsing error

我创建了名为test 的数据库,用户为test,密码为test。 但无法导入。

我尝试过的命令:-

mysql>mysql-u test -p test test > 'c:/Users/test.sql';

【问题讨论】:

  • 检查用户名和密码是否正确 mysql -u test -p test test > 'c:/Users/test.sql';

标签: mysql import mysql-error-1064


【解决方案1】:

你应该这样做 -

mysql mysql-u test -ptest test < 'c:/Users/test.sql'
  1. 密码:用 -ptest 更改 -p 测试
  2. SQL scipt:使用 更改 >

mysql — The MySQL Command-Line Tool

【讨论】:

    【解决方案2】:

    符号“>”用于导出而不是用于导入。对于导入,您需要使用 '

    使用以下命令:

    进口:

     >mysql -u username -p  databasename  < path/test.sql
    

    出口:

     >mysqldump -u username -p databasename tableName > path/test.sql
    

    【讨论】:

      【解决方案3】:

      从安全的角度来看,我不会在命令行执行中包含密码,因为它可以存储在命令历史记录中。为此,我建议以下内容

      // no quotes
      mysql -u test -p test < c:/Users/test.sql;
      
      // with quotes (i.e. directory name has spaces)
      mysql -u test -p test < "c:/Users/test.sql";
      

      你在这里指定

      mysql                    // mysql command
      -u test                  // user mysql
      -p                       // with a password
      test                     // schema name
      < c:/Users/test.sql      // Redirects the content of test.sql into mysql.  File name should not be quoted with single quotes
      

      执行该命令后,系统将提示您输入密码。

      另一种方法是在这里的另一个答案中提到的指定-ptest,因为在以这种方式使用-pYourPasswordHere 逻辑时,-p 和密码之间没有空格,但是正如我提到的那样,这将放您的密码进入命令历史记录(更适用于 linux 机器,但不要养成这样做的习惯仍然是一件好事)

      【讨论】:

      • 请您指定您正在使用的确切命令,以及您得到的确切错误吗?作为附加说明,您不应该用单引号引用文件名。如果您需要在 Windows 中引用路径,则应使用双引号。
      【解决方案4】:

      试试这个:

      语法是

      mysql <dbname> -u <username> -p<password> -e source <backup_file.sql>
      

      命令

      mysql test -u test -ptest -e source "c:/Users/test.sql"
      

      【讨论】:

        猜你喜欢
        • 2016-10-28
        • 1970-01-01
        • 2021-04-01
        • 2013-07-19
        • 2016-11-23
        • 1970-01-01
        • 2014-06-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多