Database import problem

When I issue the following command:

mysql -u user -ppassword databasename < /pathto_database.sql

I get:

sh: database_name: not found

->

and it stops processing. I have created database_name and it exists.

Can somebody help? I'm running on ubuntu 10.04

4 Replies

vishalrao,

Does the user you're using have privileges for the database you're trying to access?

MSJ

Yes the user has sufficient privileges.

@vishalrao:

sh: database_name: not found

This is odd. It indicates that the shell is treating database_name as a command it's trying to run. Does your password end with a semicolon? If so (and if the password is unquoted), the shell is interpreting your command line as two separate commands:

mysql -u user -ppassword
database_name < /path_to_database.sql

I'd suggest running mysql -u user -p databasename < /pathto_database.sql and then typing in your password when prompted. This is generally safer anyway as other users on the machine can see the arguments you used on the command line, thus exposing your password to them.

Thanks Vance. You are right. I'm new to this. I was running the above command at the "mysql" prompt and hence it was giving problems. I ran the command at "shell" prompt and it worked fine.

Thanks a lot!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct