Forrest logo
back to the mysql tool

mysql:tldr:63de1

mysql: Restore a database from a backup created with `mysqldump` (user will be prompted for a password).
$ mysql --user ${user} --password ${database_name} < ${path-to-backup-sql}
try on your machine

This command is used to import a MySQL database backup file into the specified database. Here is a breakdown of each component of the command:

  • mysql: This is the command-line client used to connect and work with MySQL databases.
  • --user ${user}: This specifies the username to use when authenticating with the MySQL server. ${user} should be replaced with the actual username.
  • --password ${database_name}: This specifies the password to use when authenticating with the MySQL server. ${database_name} should be replaced with the actual password.
  • < ${path-to-backup-sql}: This is used for input redirection, specifically it redirects the contents of the specified file to the mysql command. ${path-to-backup-sql} should be replaced with the actual path to the database backup file.

So, by executing this command, you are connecting to the MySQL server using the specified username and password, and then importing the contents of the backup SQL file into the specified database.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the mysql tool