Skip to content
This repository was archived by the owner on Nov 29, 2020. It is now read-only.

Commit c8fa873

Browse files
committed
resolve #23
1 parent edf77b0 commit c8fa873

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

5.5/import_sql.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
if [[ $# -ne 2 ]]; then
4-
echo "Usage: $0 <password> </path/to/sql_file.sql>"
3+
if [[ $# -ne 3 ]]; then
4+
echo "Usage: $0 <username> <password> </path/to/sql_file.sql>"
55
exit 1
66
fi
77

@@ -11,9 +11,9 @@ sleep 5
1111
echo " Started with PID $!"
1212

1313
echo "=> Importing SQL file"
14-
mysql -uadmin -p"$1" < "$2"
14+
mysql -u"$1" -p"$2" < "$3"
1515

1616
echo "=> Stopping MySQL Server"
17-
mysqladmin -uadmin -p"$1" shutdown
17+
mysqladmin -u"$1" -p"$2" shutdown
1818

1919
echo "=> Done!"

5.6/import_sql.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
if [[ $# -ne 2 ]]; then
4-
echo "Usage: $0 <password> </path/to/sql_file.sql>"
3+
if [[ $# -ne 3 ]]; then
4+
echo "Usage: $0 <username> <password> </path/to/sql_file.sql>"
55
exit 1
66
fi
77

@@ -11,9 +11,9 @@ sleep 5
1111
echo " Started with PID $!"
1212

1313
echo "=> Importing SQL file"
14-
mysql -uadmin -p"$1" < "$2"
14+
mysql -u"$1" -p"$2" < "$3"
1515

1616
echo "=> Stopping MySQL Server"
17-
mysqladmin -uadmin -p"$1" shutdown
17+
mysqladmin -u"$1" -p"$2" shutdown
1818

1919
echo "=> Done!"

README.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,36 @@ Usage
1515

1616
To create the image `tutum/mysql`, execute the following command on the tutum-mysql folder:
1717

18-
docker build -t tutum/mysql 5.5/
18+
docker build -t tutum/mysql 5.5/
1919

2020
To run the image and bind to port 3306:
2121

22-
docker run -d -p 3306:3306 tutum/mysql
22+
docker run -d -p 3306:3306 tutum/mysql
2323

2424
The first time that you run your container, a new user `admin` with all privileges
2525
will be created in MySQL with a random password. To get the password, check the logs
2626
of the container by running:
2727

28-
docker logs <CONTAINER_ID>
28+
docker logs <CONTAINER_ID>
2929

3030
You will see an output like the following:
3131

32-
========================================================================
33-
You can now connect to this MySQL Server using:
32+
========================================================================
33+
You can now connect to this MySQL Server using:
3434

35-
mysql -uadmin -p47nnf4FweaKu -h<host> -P<port>
35+
mysql -uadmin -p47nnf4FweaKu -h<host> -P<port>
3636

37-
Please remember to change the above password as soon as possible!
38-
MySQL user 'root' has no password but only allows local connections
39-
========================================================================
37+
Please remember to change the above password as soon as possible!
38+
MySQL user 'root' has no password but only allows local connections
39+
========================================================================
4040

4141
In this case, `47nnf4FweaKu` is the password allocated to the `admin` user.
4242

43-
Remember that the `root` user has no password but it's only accesible from within the container.
43+
Remember that the `root` user has no password but it's only accessible from within the container.
4444

4545
You can now test your deployment:
4646

47-
mysql -uadmin -p
47+
mysql -uadmin -p
4848

4949
Done!
5050

@@ -55,11 +55,11 @@ Setting a specific password for the admin account
5555
If you want to use a preset password instead of a random generated one, you can
5656
set the environment variable `MYSQL_PASS` to your specific password when running the container:
5757

58-
docker run -d -p 3306:3306 -e MYSQL_PASS="mypass" tutum/mysql
58+
docker run -d -p 3306:3306 -e MYSQL_PASS="mypass" tutum/mysql
5959

6060
You can now test your deployment:
6161

62-
mysql -uadmin -p"mypass"
62+
mysql -uadmin -p"mypass"
6363

6464
The admin username can also be set via the MYSQL_USER environment variable.
6565

@@ -70,15 +70,15 @@ Mounting the database file volume
7070
In order to persist the database data, you can mount a local folder from the host
7171
on the container to store the database files. To do so:
7272

73-
docker run -d -v /path/in/host:/var/lib/mysql tutum/mysql /bin/bash -c "/usr/bin/mysql_install_db"
73+
docker run -d -v /path/in/host:/var/lib/mysql tutum/mysql /bin/bash -c "/usr/bin/mysql_install_db"
7474

7575
This will mount the local folder `/path/in/host` inside the docker in `/var/lib/mysql` (where MySQL will store the database files by default). `mysql_install_db` creates the initial database structure.
7676

7777
Remember that this will mean that your host must have `/path/in/host` available when you run your docker image!
7878

7979
After this you can start your mysql image but this time using `/path/in/host` as the database folder:
8080

81-
docker run -d -p 3306:3306 -v /path/in/host:/var/lib/mysql tutum/mysql
81+
docker run -d -p 3306:3306 -v /path/in/host:/var/lib/mysql tutum/mysql
8282

8383

8484
Mounting the database file volume from other containers
@@ -104,17 +104,17 @@ In order to migrate your current MySQL server, perform the following commands fr
104104

105105
To dump your databases structure:
106106

107-
mysqldump -u<user> -p --opt -d -B <database name(s)> > /tmp/dbserver_schema.sql
107+
mysqldump -u<user> -p --opt -d -B <database name(s)> > /tmp/dbserver_schema.sql
108108

109109
To dump your database data:
110110

111-
mysqldump -u<user> -p --quick --single-transaction -t -n -B <database name(s)> > /tmp/dbserver_data.sql
111+
mysqldump -u<user> -p --quick --single-transaction -t -n -B <database name(s)> > /tmp/dbserver_data.sql
112112

113113
To import a SQL backup which is stored for example in the folder `/tmp` in the host, run the following:
114114

115-
sudo docker run -d -v /tmp:/tmp tutum/mysql /bin/bash -c "/import_sql.sh <rootpassword> /tmp/<dump.sql>")
115+
sudo docker run -d -v /tmp:/tmp tutum/mysql /bin/bash -c "/import_sql.sh <user> <pass> /tmp/<dump.sql>"
116116

117-
Where `<rootpassword>` is the root password set earlier and `<dump.sql>` is the name of the SQL file to be imported.
117+
Where `<user>` and `<pass>` are the database username and password set earlier and `<dump.sql>` is the name of the SQL file to be imported.
118118

119119

120120
Environment variables
@@ -123,7 +123,7 @@ Environment variables
123123
`MYSQL_USER`: Set a specific username for the admin account (default 'admin')
124124
`MYSQL_PASS`: Set a specific password for the admin account.
125125

126-
Compatibliity Issues
126+
Compatibiliity Issues
127127
--------------------
128128

129129
- Volume created by MySQL 5.6 cannot be used in MySQL 5.5 Images or MariaDB images

0 commit comments

Comments
 (0)