MySQL command line import

I always seem to forget the right command.

mysql -uroot -proot databaseName < /location/to/my/file.sql

2 Thoughts on “MySQL command line import

  1. Including any password in any command is generally a bad idea. If someone gets access to your machine, or a server under your control, all he has to do is “history | grep mysql” and you’re done for.

    As a safety measure, do mysql -u root -p database < file.sql and type your password when prompted.

  2. I used this for testing purposes. I have an alias bound to ‘mysql’ so I never have to type my username/password. You do make a valid point though!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation