Enabling MySQLx protocol support allows customers to use their MySQL instance as a document store. Further technical details on that can be found here.

MySQL initially provided support for X-DevAPI ( MySQLx) in v5.7.12 as an optional extension which can be installed by the user, but moving forward to v8.0+ it is supported by default.

To try this please go to https://aiven.io and create a new MySQL service using this link.

Once you have a running MySQL instance you will find a new tab MySQLx under Connection Information.

MySQLx is a different protocol implementation, hence the connectors need a separate port as compared to standard MySQL port and a different protocol mysqlx:// for the connection. To connect to your instance in your preferred programming language, you can use one of many available connectors from this list.

In this article we will also describe how to connect to your MySQL instance running on Aiven using Python.

  • Install the mysqlx python library by running pip install mysql-connector-python.

  • Please also copy the Service URI and the corresponding Port from your aiven-console as shown above.

  • Note that you are connecting to your MySQLx instance using the prefix mysqlx://

# create a new mysqlx session

import mysqlx
session = mysqlx.get_session(
# create a test schema
schema = session.create_schema("test")

# create a new collection in the schema
collection = schema.create_collection('food_prices')

# Add entries to this collection
{"type": "pizza", "price": "10e"},
{"type": "burger", "price": "5e"},

# Read it back:
for doc in collection.find().execute().fetch_all():
if doc.type == "pizza":
assert (doc.price == "10e")
print(f"Pizza not found, but we found {doc}")

Got here by accident? Learn how Aiven’s hosted and managed MySQL solution will simplify your workflow:

Did this answer your question?