To import a database
Create a new database and give all privileges:
mysql -u root -p CREATE DATABASE example_database; CREATE USER 'example_user'@'localhost' IDENTIFIED BY 'examplepassword';; GRANT ALL PRIVILEGES ON example_database.* TO 'example_user'@'localhost'; FLUSH PRIVILEGES; exit
Now navigate to the directory where your .sql file is.
mysql -p -u example_user example_database < file.sql (replace 'example_user', 'example_database', and 'file.sql' with the actual name.)
To Export a database
Open up terminal, making sure that you are not logged into MySQL and type,
mysqldump -u [username] -p [database name] > [database name].sql
Thanks to: https://my.bluehost.com/cgi/help/162
Thanks to: https://www.digitalocean.com/community/tutorials/how-to-import-and-export-databases-and-reset-a-root-password-in-mysql