# On the host docker run -d --rm --name mysql -e MYSQL_ROOT_HOST=localhost -e MYSQL_ALLOW_EMPTY_PASSWORD=yes mariadb:10.2.19@sha256:8263e0a4a69ee6defdea16c48ed2c2243f086a5fed3febb2d062e6e938dc7c96 docker exec -ti mysql bash # Inside the container until mysql -e "SHOW STATUS LIKE 'Connections';"; do echo "Wating for startup"; done mysql -e "CREATE USER IF NOT EXISTS 'testuser'@'%' IDENTIFIED BY 'testuser' WITH MAX_USER_CONNECTIONS 2;" # Use up two connections mysql -utestuser -ptestuser & mysql -utestuser -ptestuser & # Try a third connection mysql -utestuser -ptestuser -e "SHOW DATABASES"; # "ERROR 1226 (42000): User 'testuser' has exceeded the 'max_user_connections' resource (current value: 2)" mysql -e "ALTER USER 'testuser'@'%' WITH MAX_USER_CONNECTIONS 4;" # Still (current value 2) mysql -e "USE mysql; SELECT host, user, max_user_connections, max_connections FROM user;" # shows 4