I want to import an .sql file into a database on the server through command line.
I understand that I should use the follow line:
mysql -u username -p database_name < textfilewithsqlstatments.sql
the sql file is currently in my local folder, shall I upload it to the server first? how should I specify the directory for this file?
Thanks
The line
mysql -u username -p database_name < textfilewithsqlstatments.sql
Assumes that the file is in the same directory that you are running the command from.
You should upload the file to the server and specify the path as
mysql -u username -p database_name < /path/to/file/on/server/textfilewithsqlstatments.sql
U can use the putty utility PLINK.EXE
Preferred configure the session with a key, to not need to put the password in all the connections, so simple use:
plink mysql -u username -p database_name < textfilewithsqlstatments.sql
Considering that the file
textfilewithsqlstatments.sql
is in your /home/user.
More information about PLINK: http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter7.html
It works fine!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With