Prisma1: How to access mysql database used in local deployment

Created on 2 Nov 2017  Â·  23Comments  Â·  Source: prisma/prisma1

I can see that local deployment of graphcool framework is using MySql db. Since local deployment doesn't provide console to manage data, I want to know how to access MySql db used by local deployment.

aredocs arenext

Most helpful comment

do docker exec -it <container-mysql-id> sh then do mysql -u root -p and type graphcool as password and then use mysql command line. No need for eject. @abhitheawesomecoder

All 23 comments

If you do graphcool local eject, it shows export SQL_INTERNAL_DATABASE="graphcool" in the .envrc file, and that's used as database name in the docker-compose.yml. So I assume that should work, but haven't tested it.

But I also want to access MySql db being used and be able to run MsSql
command again the database from my local console.
On 02-Nov-2017 8:18 pm, "Kim Brandwijk" notifications@github.com wrote:

If you do graphcool local eject, it shows export SQL_INTERNAL_DATABASE="
graphcool" in the .envrc file, and that's used as database name in the
docker-compose.yml. So I assume that should work, but haven't tested it.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/graphcool/framework/issues/1125#issuecomment-341445183,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADwwTld2PkKqJO6cnA3UXjDWK-EIwf2kks5sydYogaJpZM4QPxus
.

And if possible connect interface like phpmyadmin to the MySql db being
used. So that I can get a console like graphcool cloud server.
On 02-Nov-2017 8:25 pm, "Abhishek Kumar" abhitheawesomecoder@gmail.com
wrote:

But I also want to access MySql db being used and be able to run MsSql
command again the database from my local console.
On 02-Nov-2017 8:18 pm, "Kim Brandwijk" notifications@github.com wrote:

If you do graphcool local eject, it shows export
SQL_INTERNAL_DATABASE="graphcool" in the .envrc file, and that's used as
database name in the docker-compose.yml. So I assume that should work,
but haven't tested it.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/graphcool/framework/issues/1125#issuecomment-341445183,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADwwTld2PkKqJO6cnA3UXjDWK-EIwf2kks5sydYogaJpZM4QPxus
.

You wanted to know the name of the created database. Have you actually tried connecting to it already?

I have no clue where the MySql DB for graphcool reside, after deployment. So, I haven't tried connection

do docker exec -it <container-mysql-id> sh then do mysql -u root -p and type graphcool as password and then use mysql command line. No need for eject. @abhitheawesomecoder

@Tav0. You are right, you don't need to eject either way. I just ejected to get the username/password and database name from the variables file one time.

It would be even more easy to run a standard container with phpmyadmin on the same network as the graphcool containers, so you don't need to expose the port manually.

Update: running docker run -d --link local_graphcool-db_1:db --network local_graphcool -p 8080:80 phpmyadmin/phpmyadmin works beautifully.

@Tav0 and @kbrandwijk you guys are amazing.

You made my day.

But I am curious to know, how you guys found this hidden info

@abhitheawesomecoder it's not hidden information. I have installed Kitematic on Windows, which shows me very nicely which environment variables a docker container uses, and which network it is connected to. So then it's not too hard to figure out the next steps anymore.
image

I see. I will also give it a try. Thanks again for all helpful info.
On 03-Nov-2017 6:01 pm, "Kim Brandwijk" notifications@github.com wrote:

@abhitheawesomecoder https://github.com/abhitheawesomecoder it's not
hidden information. I have installed Kitematic on Windows, which shows me
very nicely which environment variables a docker container uses, and which
network it is connected to. So then it's not too hard to figure out the
next steps anymore.
[image: image]
https://user-images.githubusercontent.com/852069/32373743-19b564e6-c09b-11e7-9308-9815099cc674.png

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/graphcool/framework/issues/1125#issuecomment-341690547,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADwwTvD-Kl1BnO0y-7IDEj0citP-QIDtks5syweJgaJpZM4QPxus
.

I added a section to the docs: https://www.graph.cool/docs/reference/deployment/database-access-eif6eing5o Thanks for pointing this out @abhitheawesomecoder 🙌

@nikolasburk Why did you choose the command-line option, instead of the graphical one?

It's easy to transfer the command line option to a 'vendor-specific' graphical one. The opposite might not be the case.

As a workaround/hack I modified the docker-compose.yml (so I wouldn't have to eject) to port forward 3306 on the db container.

Are there any caveats with this approach? Was this omitted by design?

Without cascading deletes (yet ;)) I needed a sane way to wipe db tables during tests..

There's no caveat. I have done the same on the running docker container with Kitematic on Windows. That works fine. But starting an extra docker container on the same network (either with the GUI or command line mysql tools) works better because it requires no modification of anything regarding the Graphcool docker containers.

Just fyi, I installed the latest version of prisma and I didn't need to change any config, just connected to 3307 with root/graphcool and all fine. I recommend to use Kitematic though (latest releases https://github.com/docker/kitematic/releases), pretty cool for logs, env, etc.

Can anyone tell me how to do this in Sequel Pro?

I just upgraded to Prisma 1.8.

I can successfully connect to mysql running in a server_mysql_1 container, by using this command:

docker exec -it server_mysql_1 mysql -u root --host 127.0.0.1 --port 3306 --password=prisma

but, I cannot connect to any database in Sequel Pro. Here is my settings in Sequel Pro:

host: 127.0.0.1
username: root
password: prisma
database: default@default # can run any command against this database while in terminal
port: 3307 # I have tried 3306

@tyholby, finally, this worked for me:

  1. remove your existing prisma sql server container (make sure to backup everything you will need)
  2. change docker-compose.yml adding port forwarding, like so:
mysql:
    ports: 
        - "3306:3306"
  1. run docker-compose up -d
  2. in Sequel Pro, use settings I showed above, the port should be 3306
  1. change docker-compose.yml adding port forwarding, like so:
mysql:
    ports: 
        - "3306:3306"

↑ is not worked for me:

↓ is worked for me:

services:
  mysql:
    ports:
      - '3333:3306'

sequel pro

host: 127.0.0.1
username: root
password: prisma
database: default@default
port: 3333

any suggestion on how to do this with a config like the following?

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.23
    restart: always
    ports:
      - '4466:4466'
    environment:
      PRISMA_CONFIG: |
        managementApiSecret: my-secret
        port: 4466
        databases:
          default:
            connector: mysql
            active: true
            host: prisma-db
            port: 3306
            user: root
            password: prisma
  db:
    container_name: prisma-db
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_USER: root
      MYSQL_ROOT_PASSWORD: prisma

It does not seem that port can be changed to a string underneath the PRISMA_CONFIG section.

        databases:
          default:
            connector: mysql
            active: true
            host: prisma-db
            ports: 
              - '3306:3306'

Error:

prisma_1  | Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected Int for field port, got <unset>

ok...resolved this. Just like the notes above, needed to forward to a different port and ensure the ports was listed in the db section like so:

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.23
    restart: always
    ports:
      - '4466:4466'
    environment:
      PRISMA_CONFIG: |
        managementApiSecret: my-secret
        port: 4466
        databases:
          default:
            connector: mysql
            active: true
            host: prisma-db
            port: 3306
            user: root
            password: prisma
            connectionLimit: 3
  db:
    container_name: prisma-db
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_USER: root
      MYSQL_ROOT_PASSWORD: prisma
    ports:
      - '3333:3306'
Was this page helpful?
0 / 5 - 0 ratings

Related issues

schickling picture schickling  Â·  3Comments

sedubois picture sedubois  Â·  3Comments

schickling picture schickling  Â·  3Comments

hoodsy picture hoodsy  Â·  3Comments

marktani picture marktani  Â·  3Comments