docker download image
docker pull mysql docker images
Create container
docker run -d -e MYSQL_ROOT_PASSWORD=root --name mysql57 -v /usr/local/docker_mysql/57/data/mysql:/var/lib/mysql -p 3306:3306 mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --lower_case_table_names=1 docker exec -it mysql57 bash
If an error occurs when connecting to mysql started by Docker:
ERROR 2059 (HY000): Authentication plugin caching_sha2_password’ cannot be loaded
Solution
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root'; ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; SELECT plugin FROM mysql.user WHERE User = 'root';
Stop
docker stop mysql
Start
docker start msyql
Recommended: "mysql video tutorial"
The above is the detailed content of How to start mysql in docker container on MAC computer. For more information, please follow other related articles on the PHP Chinese website!