1

I am trying to execute a query on the foodmart database in command line on Ubuntu, or better in python, if possible:

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

I tried mysql -uroot -p <foodmart_mysql.sql and I got ERROR 1046 (3D000) at line 22: No database selected. I searched for this error and I found that I need to check for 'USE databsenameor something like this in thesqlfile and make sure that it is not there. However, there is not anyUSE` command in the file.

I appreciate any help or comment.

Thanks, Afshin

2 Answers 2

1

It seems like you are going to Restore some .sql file.

Here's the code in your command line:

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

Before that locate the directory of your mysql first something like:

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

Make sure that this directory the mysql.exe is located.

then input the code above.

Good luck

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the comment. My question is what is dbnamehere? Also, I am using Ubuntu.
It is your database name from your mysql server. you have to create a database name first before you execute restore. Even you are using ubuntu. the Script is all the same. Your problem from above is you don't have a database created from your mysql server. That is why its returns you an error.
I created a db by CREATE DATABASE temp; and then entered mysql -uUsernameHere -pYourPasswordHere temp < foodmart_mysql.sqland did not get the error, but nothing happened. So, how can I see the list of the tables, or execute some queries?
run show databases then use yourDBnameCreated then show tables.
0

You have not mentioned the database name in the command. Use this command

mysql -u root database_name < foodmart_mysql.sql -p

1 Comment

Thanks for the reply. My problem was I did not had any databese. Using CREATE DATABASE temp;, I created one and now I am trying to figure out running queries in python by sqlite, which is almost done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.