CentOS7.6-Docker20安装Mysql
服务器安装 Docker基础镜像 CentOS7.6-Docker20
初始化服务器密码,使用密码登录,Linux SSH登录端口22,用户名默认root
安装centos7版本的mysql57
docker pull centos/mysql-57-centos7
列出本地镜像
docker images
运行Mysql
docker run -p 3306:3306 --name mysql57 -e MYSQL_ROOT_PASSWORD=123456 -d centos/mysql-57-centos7
查询已运行的容器
docker ps
记录 Mysql的CONTAINER ID:bee83fc2882d
根据该ID进入Mysql容器
docker exec -it bee83fc2882d bash
登录Mysql,此时数据库没有设置密码,输入密码时直接回车
$ mysql -uroot -p
如果此时直接进行用户名密码的输入会进行报错,Using a password on the command line interface can be insecure.表示在命令行输入密码是不安全的。
成功登录,设置Mysql数据库的密码
grant all privileges on *.* to 'root'@'%' identified by '你的密码';
刷新权限
flush privileges;
此时可以使用默认账户root和设置的密码登录数据库
Navicat远程访问数据库
进行连接测试,报错,指的是服务器关于ssh的加密设置没有和navicat协调好,需要对服务器的sshd_config文件进行修改。
使用指令进入配置文件
vi /etc/ssh/sshd_config
下翻,最底下找到这一行,使用i键进行文档编辑
Ciphers aes128-ctr,aes192-ctr,aes256-ctr
后面加上,3des-cbc
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc
并且加上一行
KexAlgorithms diffie-hellman-group1-sha1
使用Esc+:wq!对修改的文档进行保存
重启SSH:
service sshd restart
连接成功