在ubuntu和python中对foodmart_mysql.sql文件执行查询

时间:2019-01-18 03:54:00

标签: mysql sql

我正在尝试在Ubuntu上的命令行中对fo​​odmart数据库执行查询,或者如果可能的话,最好在python中执行查询:

http://pentaho.dlpage.phi-integration.com/mondrian/mysql-foodmart-database

我尝试了mysql -uroot -p <foodmart_mysql.sql,但得到了ERROR 1046 (3D000) at line 22: No database selected。我搜索了此错误,发现需要在文件中检查'USE databsename or something like this in the sql file and make sure that it is not there. However, there is not any USE`命令。

感谢您的帮助或评论。

谢谢, 苦参碱

2 个答案:

答案 0 :(得分:1)

似乎您要还原一些.sql文件。

这是您命令行中的代码:

mysql -u UsernameHere -p YourPasswordHere dbnamehere < "D:\sample.sql"

在此之前,首先找到您的mysql目录,如下所示:

cd C:\Program Files (x86)\MySQL\MySQL Server 6.0\bin

确保mysql.exe所在的目录。

然后输入上面的代码。

祝你好运

答案 1 :(得分:0)

您尚未在命令中提及数据库名称。使用此命令

mysql -u root database_name < foodmart_mysql.sql -p