docker 安装MySQL远程连接
1. 下载Mysql的Docker镜像:
- $ docker search mysql (搜索mysql镜像)
- $ docker pull mysql (下载mysql镜像,默认最新版本)
2. 运行镜像,设置root账号初始密码(123456),映射本地宿主机端口3306到Docker端口3306。测试过程没有挂载本地数据盘:
- $ docker run -it --rm --name mysql -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -d mysql
3. 查看已运行的容器:
- $ docker ps -a
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- a42f31094df5 mysql "docker-entrypoint.s…" 7 seconds ago Up 6 seconds 0.0.0.0:3306->3306/tcp mysql
4. 进入mysql容器:
- docker exec -it mysql bash
- root@a42f31094df5:/#
5. 在容器内登陆Mysql:
- root@a42f31094df5:/# mysql -uroot -p123456 或 (mysql -uroot -p )
- 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 9
- Server version: 8.0.11 MySQL Community Server - GPL
- Copyright (c) 2000, 2018, 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.
- mysql>
6. 查看用户信息
- mysql> select host,user,plugin,authentication_string from mysql.user;
- +-----------+------------------+-----------------------+------------------------------------------------------------------------+
- | host | user | plugin | authentication_string |
- +-----------+------------------+-----------------------+------------------------------------------------------------------------+
- | % | root | caching_sha2_password | $A$005$^]RQB}j~t! .#v)3.UogPRFu8VJA5/GKEbK5edEQlMT5sHw2n72zYJNlIbo3 |
- | localhost | mysql.infoschema | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
- | localhost | mysql.session | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
- | localhost | mysql.sys | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
- | localhost | root | caching_sha2_password | $A$005$Y6&q!59^Fmh)@-6TG58J3F5+3I/HI9L|JCadNG+-+d6W+1D_UFW+7MRD7F3 |
- +-----------+------------------+-----------------------+------------------------------------------------------------------------+
备注:host为 % 表示不限制ip localhost表示本机使用 plugin非mysql_native_password 则需要修改密码
navicat链接错误;我们继续往下看;
- 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)
- mysql>
7..连接数据库的
连接成功了。
docker 安装MySQL远程连接的更多相关文章
- docker部署mysql远程连接 解决1251 client does not support ..
现象:用虚拟机上Docker启动mysql之后无法在本地安装的navicat上远程连接已启动的mysql,错误截图: 原因:mysql 8.0 默认使用 caching_sha2_password 身 ...
- 使用docker安装mysql并连接
1.查找镜像: docker search mysql 也可以去官网查看镜像tag,选择自己需要的版本,否则会下载最新版本:https://hub.docker.com/_/mysql/ 2.下载镜像 ...
- linux安装mysql全纪录[包括yum和rpm安装,编码,远程连接以及大小写问题]
linux安装mysql全纪录[包括yum和rpm安装,编码,远程连接以及大小写问题] 一.查看mysql是否已经安装 使用“whereis mysql”命令来查看mysql安装路径: [root@h ...
- mysql 安装 和 mysql 远程连接
一.mysql安装 1.下载MySQL数据库可以访问官方网站:https://www.mysql.com/ 2.点击DOWNLOADS模块下的Community模块下的MySQL Community ...
- 云服务器Apache+MySQL(远程连接)+PHP等环境安装2021.5.9号配置
云服务器Apache+MySQL(远程连接)+PHP等环境安装2021.5.9号配置 Linux版本:centos8.2 (其他版本提供适配) 安装方式:yum 今天使用centos8系统搭建了下云主 ...
- 使用Docker安装Mysql
最近使用阿里云服务器,学习一下Docker,今天学着使用Docker安装MySQL. 首先,从阿里云的Docker Hub 上pull一个MySQL的image. [centos@loovelj~]$ ...
- [转]Docker学习之四:使用docker安装mysql
本文转自:https://blog.csdn.net/qq_19348391/article/details/82998391 Docker学习之一:注册Docker Hub账号 Docker学习之二 ...
- docker 安装mysql mongo
Docker安装Mysql 1.拉取镜像 docker pull mysql/mysql-server 2.运行mysql docker run -d -p : --name [Name] [Imag ...
- 安装docker并使用docker安装mysql
安装Docker 1. Docker 教程地址:https://www.runoob.com/docker/centos-docker.install.html 2.安装docker 命令:yum i ...
随机推荐
- php Socket表单提交学习一下
<?php //发送请求指定的页面 $file = "1.php"; $filename = "gitignore.txt"; //文件名 $path = ...
- 编程填空:第i位取反
总时间限制: 1000ms 内存限制: 1024kB描述写出函数中缺失的部分,使得函数返回值为一个整数,该整数的第i位是n的第i位取反,其余位和n相同 请使用[一行代码]补全bitManipulati ...
- yum安装提示错误Thread/process failed: Thread died in Berkeley DB library
问题描述: yum 安装更新提示 rpmdb: Thread/process failed: Thread died in Berkeley DB library 问题解决: 01.删除yum临时库文 ...
- 转:修改ETM,用Ogre实现《天龙八部》地形与部分场景详解
本文主要讲的是<天龙八部>游戏的地形和一部分场景的具体实现,使用C++, Ogre1.6,我摸索了段时间,可能方法用的并不是最好的,但好歹实现了.文章可能讲得有点罗嗦,很多简单的东西都讲了 ...
- 【虚拟化系列】VMware vSphere 5.1 简介与安装
一. VMware vSphere 5.1简介 vSphere是VMware推出的基于云计算的新一代数据中心虚拟化套件,提供了虚拟化基础架构.高可用性.集中管理.监控等一整套解决方 ...
- Redis学习之路(005)- redis内存数据库C客户端hiredis API 中文说明
A)编译安装 make make install (/usr/local) make install PREFIX=$HOME/progs(可以自由指定安装路径) B)同步的API接口 redisCo ...
- mysql insert if not exists防止插入重复记录的方法(转)
MySQL 当记录不存在时插入(insert if not exists) 在 MySQL 中,插入(insert)一条记录很简单,但是一些特殊应用,在插入记录前,需要检查这条记录是否已经存在,只有当 ...
- iOS-获取当前View所在的控制器
用一个分类,具体: .h #import <UIKit/UIKit.h> @interface UIView (CurrentController) /** 获取当前View的控制器对象 ...
- Junit 4.x 单元测试,参数化测试,套件测试 实例
对下面三个类进行单元测试 ,组成套件测试. public class Calculate { public int add(int a, int b) { return a + b; } public ...
- Spark+Hadoop+IDE环境搭建
下载地址:https://download.csdn.net/download/u014028392/8841545