Hello,
I have a sql file that is related to a website and contains user information such as username, password, etc. I have some questions:
1- I uploaded this sql file to the database using docker compose as follows:
db:
image: mariadb:latest
container_name: db
restart: unless-stopped
environment:
MARIADB_ROOT_PASSWORD: rootsecret
MARIADB_DATABASE: laravel_db
MARIADB_USER: laravel_user
MARIADB_PASSWORD: secret
volumes:
- mariadb_data:/var/lib/mysql
- ./mysql/my.cnf:/etc/mysql/my.cnf
- ./file.sql:/docker-entrypoint-initdb.d/file.sql
ports:
- "3306:3306"
I logged into the container and viewed the tables using the SHOW TABLES;
command. I deleted the line that imported file.sql
and stopped and restarted the container. All the data was deleted:
# mariadb -ularavel_user -psecret laravel_db
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 11.7.2-MariaDB-ubu2404 mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [laravel_db]> SHOW TABLES;
Empty set (0.001 sec)
MariaDB [laravel_db]>
Why?
2- In the database.php
file for Laravel I saw the following information:
'mariadb' => [
'driver' => 'mariadb',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_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'),
]) : [],
],
As you can see, the database name is laravel
. Do I also need to change laravel_db
to laravel
in the compose file?
3- Suppose I have 10 Laravel projects with different databases. If I use the mariadb:latest
image in the compose file of each of these projects, will there be any conflict? Does each project have its own image?
Thank you.