Importing SQL File in mySQL

I logged into the mysql from the command line using the following command and in addition to that I was trying to import the sql file into the database as follows in the same line:

[username@abc-xyz web_app]$ mysql -u root -pmypassword -Dtestdb < TestDB.sql

Where, testdb is the name of the database.

Note: web_app is the folder where I have my TestDB.sql file present which I want to import it into the database.

After running the above command, nothing happens but I see a warning :

Warning: Using a password on the command line interface can be insecure.

Please let me know what am I doing wrong?

I was a bit confused when I first got that one myself.

I guess the logic behind it is that someone could look over my shoulder and see it?

Anyway, try the same command using only “-p” without the password after it.
You should then get a prompt for
Enter password:
where what you enter will be displayed as asterisks.

Hi @Mittineague,

Thanks for your reply. I did what you said and it did ask me to enter password Enter password. When I entered the password, it didn’t show asterisks and everything was blank. So I entered my password and I got the prompt [username@abc-xyz web_app]$ again.

Secondly, I can successfully get the mysql prompt using the following command [username@abc-xyz web_app]$ mysql -u root -pmypassword. So password seems to be working here.

The problem I am having here is trying to figure out how to import the sql file into the database testdb

I am using MySQL 5.6 version

Instead of using “mysql” you would have better luck using “mysqlimport”?

It should be in the same bin folder, but double check the command.

Thanks, the original command [username@abc-xyz web_app]$ mysql -u root -pmypassword -Dtestdb < TestDB.sql worked for me for some reason which wasn’t working yesterday.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.