Import, export and make backups of MySQL/MariaDB databases.
Easy with Basher
basher install nelson6e65/bash-mysql-helperDone!
mysql-helper uses a .env file to read database credentials.
Example of a .env file content:
# Optional
DB_HOST='localhost'
DB_PORT=3306
# Mandatory
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
# Other stuffs not used by `mysql-helper`...It creates a backup file: {database}_{date}.sql.gz file.
mysql-helper b
mysql-helper backupYou can ignore backup creation by using --no-backup
Exports DB to {database}.sql file.
mysql-helper e
mysql-helper export
# mysql-helper -e # DEPRECATED
# mysql-helper --export # DEPRECATEDImport a database content from {database}.sql file.
mysql-helper i
mysql-helper import
# mysql-helper -i # DEPRECATED
# mysql-helper --import # DEPRECATEDNote: By default it will run
backupautomatically. To avoid this, pass--no-auto-backup.
By default, it will use the working directory to search files. In order to use a different target-dir:
mysql-helper (i|e|b) <target-dir>
mysql-helper (i|e|b) --target <target-dir> # DEPRECATEDUse --help to see more options.
mysql-helper --helpSome tools used: