...
create a new folder: database_mysql
create a new text file inside the folder called: docker-compose.yml
add this code snipped into the file …
Code Block | ||
---|---|---|
| ||
version: '3' services: db: image: mysql:5.78 container_name: db environment: MYSQL_DATABASEROOT_PASSWORD: daselementroot MYSQL_ROOT_PASSWORD: root_password MYSQL_USER: db_userdbuser MYSQL_PASSWORD: db_user_passdbuser ports: - 3306:3306 volumes: - dbdatamysql-data:/var/lib/mysql phpmyadmin: image: phpmyadmin/phpmyadmin container_name: pma links: - db environment: PMA_HOST: db PMA_PORT: 3306 PMA_ARBITRARY: 1 restart: always ports: - 8081:80 volumes: dbdata mysql-data:. |
Run this command to start the database:
Code Block |
---|
docker-compose up -dd |
In a web browser you can now access phpMyAdmin: http://localhost:8081
Login as root user. Login information as defined in the docker-compose.yml file.
...
Change the database user privileges
Info |
---|
If you setup a database user, please make sure to grant all privileges to that user. |
Use phpMyAdmin (need to be logged in as root user) or login with the terminal via mysql
mysql> GRANT ALL PRIVILEGES on *.* TO 'dbuser'@'localhost';
...