Hello,
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 deleted the line that imported file.sql
and stopped and restarted the container via:
# docker compose down db
# docker compose up db -d
I added a user to the database via PhpMyAdmin and the following command:
INSERT INTO `branches` (`title`, `created_at`, `updated_at`)
SELECT 'Main Branch', NOW(), NOW()
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM `branches` WHERE `title` = 'Main Branch');
INSERT INTO `charts` (`title`, `created_at`, `updated_at`)
SELECT 'Default Chart', NOW(), NOW()
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM `charts` WHERE `title` = 'Default Chart');
INSERT INTO `users` (
`name`, `family`, `mobile`, `email`, `password`,
`role_id`, `branch_id`, `chart_id`, `created_at`, `updated_at`
) VALUES (
'Test Name',
'Test Family',
'12345678910',
'test@example.com',
'$2y$12$L9T5PJp/hgaG4rY8CURYQerxlvtnSs2/KsB8U0OwPzVy2Fuj5Aisu', -- bcrypt hash of '123456789'
1, -- Using the existing 'user' role ID
(SELECT id FROM `branches` WHERE `title` = 'Main Branch' LIMIT 1),
(SELECT id FROM `charts` WHERE `title` = 'Default Chart' LIMIT 1),
NOW(),
NOW()
);
I can log in with username 12345678910
and password 123456789
. I stopped and restarted the container using the following commands:
# docker compose down db
# docker compose up db -d
The user I added has been deleted and I can’t log in to the website again. The following error is displayed in the browser console:
POST http://Server_IP/api/login 401 (Unauthorized)
Why?
Thank you.