I use MySQL in a project and have to switch to MariaDB. So far I know, it is the same, the only thing I have to do is, to change the image from: image: 'mysql/mysql-server:8.0' to image: 'mariadb:latest' because it should the same.
docker-compose.yml
mysql:
image: 'mariadb:latest'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- 'sail-project-mysql:/var/lib/mysql'
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
networks:
- sail
healthcheck:
test:
- CMD
- mysqladmin
- ping
- '-p${DB_PASSWORD}'
retries: 3
timeout: 5s
database.php
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'mysql'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
.env
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=<database_name>
DB_USERNAME=<username>
DB_PASSWORD=<password>
sail artisan migrate
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] No such file or directory (Connection: mysql, SQL:
select
table_name as `name`,
(data_length + index_length) as `size`,
table_comment as `comment`,
engine as `engine`,
table_collation as `collation`
from information_schema.tables
where table_schema = '<database_name>'
and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)
I run sail artisan up --build and i run successful.
There DB server is online in Docker an there is no error in the log
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] Starting MariaDB 11.2.2-MariaDB-1:11.2.2+maria~ubu2204 source revision 929532a9426d085111c24c63de9c23cc54382259 as process 1
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: Number of transaction pools: 1
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: Using ARMv8 crc32 + pmull instructions
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: Using liburing
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: Completed initialization of buffer pool
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: End of log at LSN=47959
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: Opened 3 undo tablespaces
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: 128 rollback segments in 3 undo tablespaces are active.
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: log sequence number 47959; transaction id 16
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] Plugin 'FEEDBACK' is disabled.
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] Plugin 'wsrep-provider' is disabled.
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] InnoDB: Buffer pool(s) load completed at 240121 17:34:25
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] Server socket created on IP: '0.0.0.0'.
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] Server socket created on IP: '::'.
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] mariadbd: Event Scheduler: Loaded 0 events
2024-01-21 18:34:25 2024-01-21 17:34:25 0 [Note] mariadbd: ready for connections.
2024-01-21 18:34:25 Version: '11.2.2-MariaDB-1:11.2.2+maria~ubu2204' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
In the doc of Laravel I don't find some information about this. Which config is missing, or wrong in my case?