How to access to the graphcool database using CLI or PhpMyAdmin

I’ve an already mounted containers using the name of users-permissions, and this is the list of the containers:

04db65cb9ba7        graphcool/graphcool-dev:0.11.1   "/app/bin/single-ser…"   2 hours ago         Up 2 hours          0.0.0.0:60000->60000/tcp         users_permissions_graphcool_1
bab62d6ed0ec        mysql:5.7                        "docker-entrypoint.s…"   2 hours ago         Up 2 hours          3306/tcp, 33060/tcp              users_permissions_graphcool-db_1
f26d74765251        graphcool/localfaas:0.11.1       "/app/bin/localfaas"     2 hours ago         Up 2 hours          0.0.0.0:60050->60050/tcp         users_permissions_localfaas_1

As you already see the container that hold our database is using the name users_permissions_graphcool-db_1, this container is create from an mysql:5.7 server, and I’ve two solutions to access to it, one uses CLI and a second one uses Phpmyadmin.

CLI Solution

In this solution you’ve to execute /bin/bash from the users_permissions_graphcool-db_1 container:

docker exec -it users_permissions_graphcool-db_1 /bin/bash

After your get access to the container, now you have to access to mysql using the username root and the password graphcool:

[email protected]:/# mysql -uroot -pgraphcool
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 144
Server version: 5.7.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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>

If you’re not sure about the username and the password you can access to the file .envrc using the command graphcool local eject and find SQL_CLIENT_USER and SQL_CLIENT_PASSWORD.

Now you can use mysql commands and this is an example of listing the databases:

mysql> SHOW DATABASES;
+---------------------------+
| Database                  |
+---------------------------+
| information_schema        |
| cjmvub207000401850n7pygxg |
| graphcool                 |
| logs                      |
| mysql                     |
| performance_schema        |
| sys                       |
+---------------------------+
7 rows in set (0.00 sec)

PhpMyAdmin

If you’re not a fan of using command lines, you can opt for this solution, and to do so you’ve to start a phpmyadmin container on the same network as the graphcool containers using this command:

docker run -d --link users_permissions_graphcool-db_1:db --network users_permissions_graphcool -p 8080:80 phpmyadmin/phpmyadmin

Browse to http://localhost:8080 and use the root for the username and graphcool for the password

Leave a Reply

Your email address will not be published. Required fields are marked *