From c2ecbf5e112566d7ecd5b782e2f76138fcad643e Mon Sep 17 00:00:00 2001 From: hugo gogo Date: Mon, 5 Sep 2022 11:41:06 +0200 Subject: [PATCH] baby steps on mariadb configuration --- README.md | 39 +++++++++++++++++++++++++++- srcs/docker-compose.yml | 13 ++++++++-- srcs/requirements/mariadb/Dockerfile | 3 +++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 969f346..3853b47 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ - [go inside docker to debug it](https://docs.docker.com/engine/reference/commandline/container_exec/) - `docker exec -ti bash` to run bash inside a running container - [docker CMD vs ENTRYPOINT](https://phoenixnap.com/kb/docker-cmd-vs-entrypoint) +- [use env variable with compose](https://docs.docker.com/compose/environment-variables/) ###### docker pid 1 - nginx by default will create some child process (a master and some workers), then it quits (doc ?) @@ -118,6 +119,9 @@ - bind mounts are normal files anywhere on the computer, that docker container can access with absolut path and modify. They can also be modified without docker, since they are juste files - volumes are only modifiable by docker, they don't need an absolut path, and they are not dependent of host architecture + ###### psswd in dockerfile : + - [SO securing passwords in dockerfiles](https://stackoverflow.com/questions/22651647/docker-and-securing-passwords) + #### nginx - [nginx begginer guide](https://hub.docker.com/_/nginx/) - [nginx all directives for conf file](https://nginx.org/en/docs/dirindex.html) @@ -144,8 +148,41 @@ - "server" runs in the background and listen for inputs - "client" interpret the commands to communicate with "server" - sudo apt install mariadb-client mariadb-server -- [ERROR 1698 (28000): Access denied for user 'root'@'localhost'](https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost) - [wiki ubuntu mariadb](https://doc.ubuntu-fr.org/mariadb) +- [list of directives](https://mariadb.com/kb/en/sql-statements/) +- [ERROR 1698 (28000): Access denied for user 'root'@'localhost'](https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost) +- [ERROR 1698 (28000): Access denied for user 'root'@'localhost' 2](https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7#answer-1003892) +- [meaning of % SO](https://stackoverflow.com/questions/12931991/mysql-what-does-stand-for-in-host-column-and-how-to-change-users-password) +- [meaning of % doc](https://doc.ubuntu-fr.org/mysql#connexions_entrantes) +- `%` means all entrant connections, while `localhost` means only localhost connections +- [mysql commande line](https://mariadb.com/kb/en/mysql-command-line-client/) +- [use mysql in script](https://stackoverflow.com/questions/59608632/mariadb-create-database-and-execute-sql-script-without-character-from-the) + + ###### mariadb basic commands : + - create user : + ``` + # mysql -u root + use mysql; + CREATE USER 'some_user'@'%' IDENTIFIED BY 'some_pass'; + GRANT ALL PRIVILEGES ON *.* TO 'some_user'@'%' WITH GRANT OPTION; + FLUSH PRIVILEGES; + ``` + - show users : + ``` + SELECT User, Host, plugin FROM mysql.user; + ``` + - delete user : + ``` + DROP USER ; + ``` + - show databases : + ``` + SHOW DATABASES; + ``` + - delete database : + ``` + DROP DATABASE ; + ``` #### php-fpm - [](https://en.wikipedia.org/wiki/FastCGI) diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml index add7715..35a724e 100644 --- a/srcs/docker-compose.yml +++ b/srcs/docker-compose.yml @@ -10,8 +10,8 @@ version: "3.8" services: # --------------------------------- - test: + build: context: ./requirements/test dockerfile: Dockerfile @@ -19,8 +19,8 @@ services: container_name: mytest # --------------------------------- - nginx: + # restart: on-failure ports: - "80:80" @@ -31,5 +31,14 @@ services: image: nginx container_name: mynginx +# --------------------------------- + mariadb: +# restart: on-failure + build: + context: ./requirements/mariadb + dockerfile: Dockerfile + image: mariadb + container_name: mymariadb + # --------------------------------- diff --git a/srcs/requirements/mariadb/Dockerfile b/srcs/requirements/mariadb/Dockerfile index 695b29d..1c0b068 100644 --- a/srcs/requirements/mariadb/Dockerfile +++ b/srcs/requirements/mariadb/Dockerfile @@ -2,3 +2,6 @@ FROM debian:buster RUN apt update && apt install -y mariadb-client mariadb-server +RUN mariadb --execute="create database db_hugo_test; create user 'u_hugo_test'@'localhost' identified by 'hello'; grant all privileges on *.* to 'u_hugo_test'@'localhost' with grant option;" + +CMD [ "mysqld" ]