MySQL preview¶
Table of contents
Introduction¶
We are in the process of launching support for MySQL, and we have a preview available for you to try.
Supported MySQL versions
Hasura GraphQL engine currently supports MySQL 8.0.14 and above. Support for earlier versions will be added soon.
Try it out¶
MySQL support can be tried out using docker-compose
and an existing MySQL database
as follows:
Prerequisites¶
- Docker
- Docker Compose
- An existing MySQL database
Step 1: Get the docker-compose file¶
Get the Hasura MySQL preview docker compose file:
# in a new directory run
wget https://raw.githubusercontent.com/hasura/graphql-engine/master/install-manifests/docker-compose-mysql-preview/docker-compose.yaml
# or run
curl https://raw.githubusercontent.com/hasura/graphql-engine/master/install-manifests/docker-compose-mysql-preview/docker-compose.yaml -o docker-compose.yaml
Step 2: Update MySQL config¶
You need to now update the docker-compose.yaml
file with credentials for your
MySQL database (replace the values surrounded by <>)
...
command:
- graphql-engine
- --mysql-host
- <mysql-host>
- --mysql-user
- <mysql-user>
- --mysql-port
- <mysql-port>
- --mysql-dbname
- <mysql-dbname>
- --mysql-password
- <mysql-password>
...
Our docker networking guide might be useful to set
the appropriate value for mysql-host
. (See Hasura to API)
Step 3: Run Hasura GraphQL engine¶
The following command will run Hasura along with a Postgres database required for its functioning.
$ docker-compose up -d
Check if the containers are running:
$ docker ps
CONTAINER ID IMAGE ... CREATED STATUS PORTS ...
097f58433a2b hasura/graphql-engine ... 1m ago Up 1m 8080->8080/tcp ...
b0b1aac0508d postgres ... 1m ago Up 1m 5432/tcp ...
Step 4: Try out the GraphQL API¶
The GraphiQL on the Hasura console available at http://localhost:8080/console
can be
used to try out the generated GraphQL API.
The Hasura console currently does not support managing the MySQL database schema.
i.e. The Data
section of the console will not display the MySQL tables, etc. Hence the database
schema needs to be managed externally as of now. (support for this is coming very soon)
See the source PR for more information on current limitations and upcoming features.
Give us feedback¶
We appreciate any feedback. Please open a new GitHub discussion, and we can discuss there.