Here is a simple docker-compose file to run MySQL + phpMyAdmin services for your development needs.
Create a file docker-compose.yml.
Copy and paste the below code.
Run it using the command docker-compose up.
version: "3"
services:
# Database
db:
platform: linux/x86_64
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: yourdb
MYSQL_PASSWORD: password
networks:
- mysql-phpmyadmin
# phpmyadmin
phpmyadmin:
depends_on:
- db
image: phpmyadmin
restart: always
ports:
- "8090:80"
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: password
networks:
- mysql-phpmyadmin
networks:
mysql-phpmyadmin:
volumes:
db_data:
You can access the phpMyAdmin at http://localhost:8090/
Top comments (4)
Returns:
mysqli::real_connect(): (HY000/1045): Access denied for user 'root'@'{LocalHostIpAddress}' (using password: YES)
Same thing happens with any other user made.
First step login root/your-mysql-password in your local phpmyadmin
it returns:
mysqli::real_connect(): (HY000/1045): Access denied for user 'root'@'{LocalHostIpAddress}' (using password: YES)
docker exec -it <container_name_mysql> mysql -u root -p
( you can get from: docker ps)
it will ask password of MYSQL_ROOT_PASSWORD
after accessing mysql, run command:
CREATE USER 'root'@'192.168.0.4' IDENTIFIED BY 'password';
(192.168.0.4 is LocalHostIpAddress, replace it)
run command:
FLUSH PRIVILEGES;
done!
login with root/your-mysql-password again!
I know this is an old post. But thanks it worked for me as well
@hungdev, 🔥 🔥 This worked for me. I think the author should just include it in the tutorial