docker run --name mysql --env MYSQL_ROOT_HOST=172.17.%.% --env MYSQL_ROOT_PASSWORD=123456 -v /usr/local/mysql-docker:/var/lib/mysql -p 3306:3306 -d mysql/mysql-server:5.7
如果没有把本地路径 添加到Docker的文件共享目录里,可能会报如下错误:
1 2 3 4
The path /usr/local/mysql-docker is not shared from OS X and is not known to Docker. You can configure shared paths from Docker -> Preferences... -> File Sharing. See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.
bash-4.2# mysql -uroot -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 5.7.29 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.