Skip to content

Instantly share code, notes, and snippets.

@kramapet
Created May 26, 2015 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kramapet/2ff31862b477537c4792 to your computer and use it in GitHub Desktop.
Save kramapet/2ff31862b477537c4792 to your computer and use it in GitHub Desktop.
% docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0069ffd119ae mysql:5 "/entrypoint.sh mysq 7 minutes ago Up 7 minutes 0.0.0.0:49153->3306/tcp mysql
% mysql -u root -h 192.168.59.103 -P 49153 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.01 sec)
mysql> create database `hello`;
Query OK, 1 row affected (0.01 sec)
mysql> create table foo(a int primary key);
ERROR 1046 (3D000): No database selected
mysql> use hello;
Database changed
mysql> create table foo(a int primary key);
Query OK, 0 rows affected (0.02 sec)
mysql> insert into foo values (1),(2),(3),(4),(5);
Query OK, 5 rows affected (0.01 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> quit
Bye
% boot2docker shellinit
% docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0069ffd119ae mysql:5 "/entrypoint.sh mysq 9 minutes ago Up 9 minutes 0.0.0.0:49153->3306/tcp mysql
% docker stop mysql
mysql
% docker start mysql
mysql
% docker stop mysql
% docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0069ffd119ae mysql:5 "/entrypoint.sh mysq 9 minutes ago Up 3 seconds 0.0.0.0:49154->3306/tcp mysql
% mysql -u root -h 192.168.59.103 -P 49154 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hello |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.01 sec)
mysql> use hello;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from hello;
ERROR 1146 (42S02): Table 'hello.hello' doesn't exist
mysql> select * from foo;
+---+
| a |
+---+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+---+
5 rows in set (0.01 sec)
mysql> quit
Bye
%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment