Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Initial Release
Browse files Browse the repository at this point in the history
  • Loading branch information
byjg committed Aug 18, 2017
0 parents commit 0664c4f
Show file tree
Hide file tree
Showing 12 changed files with 7,975 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/node_modules/*
**/bower_components/*
21 changes: 21 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
env:
es6: true
node: true
jest: true
extends: 'eslint:recommended'
parserOptions:
sourceType: module
rules:
indent:
- error
- 4
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always
no-console: 0
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.idea
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "7"
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# USDocker for MySQL

This script creates a MySQL applicantion from a docker image.
You can persist your mysql and customize your mysql without expertise in Docker.

## Installing

```bash
npm install -g usdocker-mysql
```

## Start the mysql service

```
usdocker mysql up
```

## Stop the mysql service

```
usdocker mysql down
```

## Run the mysql-client command line interface

```
usdocker mysql client
```

## Connect to the mysql bash interface

```
usdocker mysql connect
```

## Dump the database and save it to the /tmp/dump folder.

```
usdocker mysql dump [database]
```

## Analyse the database service and get insights for tuning it

```
usdocker mysql analyse
```

## Customize your Service

You can setup the variables by using:

```bash
usdocker mysql --set variable=value
```

Default values

- image: "mysql:5.7",
- folder: "$HOME/.usdocker/data/mysql",
- port: 3306,
- rootPassword: "password" (note: only will work at the first time)


## Customize the "$HOME/.usdocker/setup/mysql/conf.d/custom.cnf"

Use your own setup for mysql changing this file.

```
[mysqld]
bind-address = 0.0.0.0
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
```

## Customize the "$HOME/.usdocker/setup/mysql/home/"

This folder exists for setup the database dump. You have only edit the file .my.cnf with the following setup:

```
[mysqldump]
user=backup
password=PasSWord
```
9 changes: 9 additions & 0 deletions mysql/conf.d/custom.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Custom MySQL.ini

[mysqld]
bind-address = 0.0.0.0

[mysqldump]
quick
quote-names
max_allowed_packet = 16M
3 changes: 3 additions & 0 deletions mysql/home/.my.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mysqldump]
user=backup
password=PasSWord
26 changes: 26 additions & 0 deletions mysql/home/mysqldump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

#USERNAME=" -u backup " # see $HOME/.my.cnf

mkdir -p /tmp/dump

if [ -z "$1" ]
then
databases=`/usr/bin/mysql --execute='show databases' --skip-column-names --batch`
else
databases="$1"
fi

COMMAND="/usr/bin/mysqldump --routines --triggers --events --comments --hex-blob "

for db in $databases
do

echo Doing $db...
$COMMAND $db > /tmp/dump/$db.sql

sed -i -e 's:\/\*!50017 DEFINER=.* \*\/::g' /tmp/dump/$db.sql
sed -i '/^\/\*\!50013/d' /tmp/dump/$db.sql

done

Loading

0 comments on commit 0664c4f

Please sign in to comment.