dotnet add package MySql.Data.EntityFrameworkCore --version 8.0.19
docker pull mysql/mysql-server:8.0.17
docker run --name=mysql1 -d -p 3306:3306 mysql/mysql-server:8.0.17
docker logs mysql1
docker logs mysql1 2>&1 | grep GENERATED
docker exec -it mysql1 mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
CREATE USER 'root'@'%' IDENTIFIED BY 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
CREATE DATABASE users_database;
create user 'dotnetuser'@'%' identified by 'dotnetpassword';
grant all on users_database.* to 'dotnetuser'@'%';
docker stop mysql1
Start again same container. Keeps the ports open. If the image, container and MySQL configuration are all set, only this command is needed to start MySQL after stopping the server or restarting the computer.
docker start mysql1
docker rm mysql1
docker rmi mysql/mysql-server