MySQL
Version
MySQL and MariaDB are optional and not installed by default - install the version(s) you need via
install, e.g. valet.sh install mysql57. You can install and run multiple versions
of each at the same time, as different TCP ports are used.
Both operating systems run the services in containers. On Ubuntu, Podman is used with the host network, so a service
stays reachable via 127.0.0.1 and its port. On macOS, each service runs as an Apple container with its own IP
address and is reachable via its DNS name in the .vsh domain, using the same port.
| Type | Version | Ubuntu | macOS |
|---|---|---|---|
| MySQL | 5.7 | 127.0.0.1:3307 | vsh-mysql57.vsh:3307 |
| MySQL | 8.0 | 127.0.0.1:3308 | vsh-mysql80.vsh:3308 |
| MySQL | 8.4 | 127.0.0.1:3309 | vsh-mysql84.vsh:3309 |
| MariaDB | 10.4 | 127.0.0.1:3317 | vsh-mariadb104.vsh:3317 |
| MariaDB | 10.6 | 127.0.0.1:3319 | vsh-mariadb106.vsh:3319 |
| MariaDB | 10.11 | 127.0.0.1:3324 | vsh-mariadb1011.vsh:3324 |
| MariaDB | 11.4 | 127.0.0.1:3329 | vsh-mariadb114.vsh:3329 |
| MariaDB | 11.8 | 127.0.0.1:3333 | vsh-mariadb118.vsh:3333 |
| MariaDB | 12.3 | 127.0.0.1:3337 | vsh-mariadb123.vsh:3337 |
Warning
The default MySQL/MariaDB is also accessed via TCP port 3306!
Manage MySQL services
Whichever version you install first becomes the default (reachable via port 3306 and the plain mysql CLI command)
unless you set a different one via service default. You can start/stop and enable/disable
each installed version via valet.sh.
# stop and disable MySQL 5.7
valet.sh service disable mysql57
# start and enable MySQL 5.7
valet.sh service enable mysql57
# stop and disable MySQL 8.0
valet.sh service disable mysql80
# start and enable MySQL 8.0
valet.sh service enable mysql80
# stop and disable MariaDB 10.6
valet.sh service disable mariadb106
# start and enable MariaDB 10.6
valet.sh service enable mariadb106
Access MySQL
MySQL via valet.sh only uses TCP for the connection. Unix sockets are deactivated! Instead of using "localhost" as host definition in your application, you have to use "127.0.0.1" and in most cases, when there is no separate port definition, append the port to the host string. e.g "127.0.0.1:3306"
Default Credentials:
| Username | Password |
|---|---|
| root | root |
Warning
Note that if you change the standard MySQL version, all configured apps with the standard port 3306 will be redirected to the new standard MySQL version. You have to create a new database, run database migrations, or export and import the db from the previous MySQL default service. You can avoid this behavior by directly using the port of the target MySQL version.
Access MariaDB
Info
Since valet.sh 2.6.0 MariaDB is part of the MySQL service handling. Mariadb can now be set as the default "mysql" version.
Default Credentials:
| Username | Password |
|---|---|
| root | root |
Info
Use mariadb10.6,mariadump10.6 or mariadb10.11,mariadump10.11 to work with a specific MariaDB version on CLI!
Custom configuration
valet.sh writes its own defaults for every installed MySQL/MariaDB version to a valet-sh.cnf file. Do not edit
that file - it is regenerated whenever valet.sh (re-)provisions the service and your changes would be lost.
Instead, every installed version gets an additional, user-writable zz-custom.cnf. valet.sh creates this file once
on installation and never overwrites it. It is read after valet-sh.cnf, so every option you set
there overrides the valet.sh defaults. The path is the same on Ubuntu and macOS:
| Type | File |
|---|---|
| MySQL | /usr/local/valet-sh/packages/mysql<version>/etc/conf.d/zz-custom.cnf |
| MariaDB | /usr/local/valet-sh/packages/mariadb<version>/etc/mariadb.conf.d/zz-custom.cnf |
<version> is the version part of the service name, e.g. /usr/local/valet-sh/packages/mysql80/etc/conf.d/zz-custom.cnf
for mysql80 or /usr/local/valet-sh/packages/mariadb106/etc/mariadb.conf.d/zz-custom.cnf for mariadb106.
The file already contains a [mysqld] section - just add your options below it:
# /usr/local/valet-sh/packages/mysql80/etc/conf.d/zz-custom.cnf
[mysqld]
innodb_buffer_pool_size = 1G
max_allowed_packet = 512M
sql-mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"
Changes are not picked up automatically - restart the service afterwards via service:
valet.sh service restart mysql80
Info
The file is specific to one version. Options set for mysql80 do not apply to mysql84 or mariadb106 -
each of them has its own zz-custom.cnf.
Warning
uninstall removes the whole package directory of a service, including your
zz-custom.cnf - even without --purge. Back the file up first if you want to keep your settings.