How to import sql file into a bash script

14,601

There is no space between the "-p" and your password.

Per mysql documentation:

These work:

-uuser_name -ppassword 
-u user_name -ppassword 

This does not:

-u user_name -p password 

http://forums.mysql.com/read.php?10,229253

Share:
14,601
maxime
Author by

maxime

Updated on June 04, 2022

Comments

  • maxime
    maxime almost 2 years

    On Debian, I want to import a huge sql file with a command in a bash script. Currently, I use this command:

    mysql -u root -p myDatabase < my_backup.sql
    

    But that's not fine in a bash script because it asks for the root password ! I tried to provide it in the command with the -p argument, but it doesn't seems to work... Do someone have a solution ?

    Thanks

  • maxime
    maxime over 10 years
    I tried mysql -u root -p="mypassword" myDatabase < my_backup.sql, but it denies the access... :(
  • Mark Setchell
    Mark Setchell over 10 years
    You need to drop the equals sign and double-quotes.