#cli #mysql

Command to import DB through the command line in MySQL

upload your SQL file to the serve through FTP. Ones the file is on server you can user the following command.

Assumptions

  • you have created a DB
  • you have already create a DB user with privileges as per required.
  • you have ssh access to the server
  • you know how to log in through ssh into your server.

Command

mysql -u db_user_name -p db_name < /complete/file/path.sql

If you are using amazon RDS, you need to alter the command by adding the host to the command

mysql -h host -u db_user_name -p db_name < /complete/file/path.sql

Queries and comments are welcome.

mohammed-samgan-khan

Hi, I am Samgan, I excel at solving complex problems involving logic and step by step breakdown of the problem. Besides, to develop complex algorithms, I specialise in problem framing, systems design, and product development strategy. Sometimes I also enjoy public speaking.  

I am also the creator of penit.ink, a site which provides young writers with a free hand place to show their creation to the world. Irrespective of the niche, if you write this place is defiantly for you.