docker pull mysql
docker run --name mysql -e MYSQL_ROOT_PASSWORD=123456 -v /usr/local/mysql/logs:/logs -v /usr/local/mysql/data:/var/lib/mysql -p 3306:3306 -d mysql
启动mysql,设置密码和端口
CREATE USER 'test'@'%' IDENTIFIED WITH mysql_native_password BY 'fengzi2141!@#'; GRANT ALL PRIVILEGES ON *.* TO 'test'@'%'; FLUSH PRIVILEGES;