Question

How to import sql file into MySQL?

You answered my question about phpmyadmin but I can’t find it nor the command lines. I know how to SFTP my .sql file to the new droplet, but the mysql command to import it into the database is gone.

Seems like this entire site changed overnight and I just started!


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Let’s say you want to import a mysql dump into a new database with a new user. <br>Where your mysqldump is source.sql <br> <br># Enter into MySQL using “root” user identified by password <br>mysql -u root -p <br> <br>#Create the database <br>mysql> CREATE DATABASE NEWDB; <br> <br>#Create the user <br>mysql> CREATE USER ‘newuser’@‘localhsot’ IDENTIFIED BY ‘newpass’; <br> <br>#Grant ALL privileges onthe new database to the new User <br>mysql> GRANT ALL PRIVILEGES ON NEWDB.* TO ‘newuser’@‘localhost’ IDENTIFIED BY ‘newpass’; <br> <br>#Switch to the New Database <br>mysql> USE NEWDB; <br> <br>#Insert data from source.sql <br>mysql> SOURCE source.sql

mysql db_name < script.sql

Thanks for all of those ways to import into mysql. I got that working. Yay.