Close Up Photo of Mining Rig

How to Import MySQL Database or SQL File

Manage your MySQL databases with ease! This guide provides clear instructions for importing existing SQL files and exporting databases as backups. Learn the essential commands and gain control over your data.

  • Access MySQL with Root User
mysql -u root -p
  • Create New Database
Syntax:- CREATE DATABASE Database_name;
Example:- CREATE DATABASE osmsdb;
  • Access Newly Created Database
Syntax:- USE Database_name;
Example:- USE osmsdb;
  • Import Database or SQL File
Syntax:- source sql_file_path
Example:- source /var/myimporteddb/osmsdb.sql

How to Export MySQL Database as SQL File

  • Export MySQL Database as SQL File
Syntax:- mysqldump -u db_user_name -p Database_Name > File_Path/File_Name.sql
Example:- mysqldump -u root -p dps > /var/myexporteddb/dps.sql