项目作者: nelson6e65

项目描述 :
Import, export and make backups of MySQL/MariaDB databases using .env file
高级语言: Shell
项目地址: git://github.com/nelson6e65/bash-mysql-helper.git
创建时间: 2019-02-19T09:11:37Z
项目社区:https://github.com/nelson6e65/bash-mysql-helper

开源协议:MIT License

下载


mysql-helper

Import, export and make backups of MySQL/MariaDB databases.

Installing

Easy with Basher

  1. basher install nelson6e65/bash-mysql-helper

Done!

Configuring

mysql-helper uses a .env file to read database credentials.

Example of a .env file content:

  1. # Optional
  2. DB_HOST='localhost'
  3. DB_PORT=3306
  4. # Mandatory
  5. DB_DATABASE=
  6. DB_USERNAME=
  7. DB_PASSWORD=
  8. # Other stuffs not used by `mysql-helper`...

Usage

Backup Database

It creates a backup file: {database}_{date}.sql.gz file.

  1. mysql-helper b
  2. mysql-helper backup

You can ignore backup creation by using --no-backup

Exporting Database to SQL

Exports DB to {database}.sql file.

  1. mysql-helper e
  2. mysql-helper export
  3. # mysql-helper -e # DEPRECATED
  4. # mysql-helper --export # DEPRECATED

Importing SQL to Database

Import a database content from {database}.sql file.

  1. mysql-helper i
  2. mysql-helper import
  3. # mysql-helper -i # DEPRECATED
  4. # mysql-helper --import # DEPRECATED

Note: By default it will run backup automatically. To avoid this, pass --no-auto-backup.

Customize target dir

By default, it will use the working directory to search files. In order to use a different target-dir:

  1. mysql-helper (i|e|b) <target-dir>
  2. mysql-helper (i|e|b) --target <target-dir> # DEPRECATED

More options

Use —help to see more options.

  1. mysql-helper --help

Credits

Some tools used: