We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
运行 docker pull mysql
[root@MyCentos7-1 ~]# docker pull mysql Using default tag: latest latest: Pulling from library/mysql 85b1f47fba49: Pull complete 2a809168ab45: Pull complete Digest: sha256:1a2f9361228e9b10b4c77a651b460828514845dc7ac51735b919c2c4aec864b7 Status: Downloaded newer image for mysql:latest
[root@MyCentos7-1 ~]# docker run --restart=always --name kitking-mysql -e MYSQL_ROOT_PASSWORD=rad_xxx -p 3306:3306 -d mysql eb3dbfb0958f5c856323e4d8da60d43194884ff05d7adac1ec059adb66ac7f7b
docker run是启动容器的命令;
docker run
--name:指定了容器的名称,方便之后进入容器的命令行
-itd:其中,i是交互式操作,t是一个终端,d指的是在后台运行
-p:指在本地生成一个随机端口,用来映射mysql的3306端口
3306
-e:设置环境变量
MYSQL_ROOT_PASSWORD=emc123123:指定了mysql的root密码
mysql:指运行mysql镜像
运行 docker exec -it kitking-mysql /bin/bash
docker exec -it kitking-mysql /bin/bash
[root@MyCentos7-1 ~]# docker exec -it kitking-mysql /bin/bash root@my-mysql-v1-nths4:/usr/local/mysql#
运行 mysql -uroot -p
mysql -uroot -p
root@my-mysql-v1-nths4:/usr/local/mysql# mysql -uroot -p Enter password: mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.02 sec)
接着,由于mysql中root执行绑定在了localhost,因此需要对root进行授权,代码如下,
localhost
mysql> ALTER user 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; Query OK, 0 rows affected (0.01 sec) mysql> mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.01 sec)
最后,使用navitecat测试mysql连接,如下,
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1:获取MySQL镜像
运行 docker pull mysql
2:启动MySQL镜像
docker run
是启动容器的命令;--name:指定了容器的名称,方便之后进入容器的命令行
-itd:其中,i是交互式操作,t是一个终端,d指的是在后台运行
-p:指在本地生成一个随机端口,用来映射mysql的
3306
端口-e:设置环境变量
MYSQL_ROOT_PASSWORD=emc123123:指定了mysql的root密码
mysql:指运行mysql镜像
3:进入MySQL容器
运行
docker exec -it kitking-mysql /bin/bash
4:进入MySQL
运行
mysql -uroot -p
5:进行配置,使外部工具可以连接
接着,由于mysql中root执行绑定在了
localhost
,因此需要对root进行授权,代码如下,最后,使用navitecat测试mysql连接,如下,
The text was updated successfully, but these errors were encountered: