当前位置:网站首页>docker部署mysql 实现远程连接[通俗易懂]
docker部署mysql 实现远程连接[通俗易懂]
2022-07-28 12:12:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
1.docker search mysql 查看mysql版本
2.docker pull mysql 要选择starts最高的那个name 进行下载
3.docker images 查看下载好的镜像
4.启动mysql实例
docker run –name dockermysql -p 3307:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql
–name 为mysql的实例设置别名。 -p 3307为对外暴露的端口。3306是内部端口
-e MYSQL_ROOT_PASSWORD 设置mysql登录密码 -d 以守护进程运行(后台运行) 最后的mysql是镜像名称
5. docker ps -a 查看在运行的
6. docker exec -it dockermysql bash 进入容器内部 dockermysql 是上边运行时为容器取的别名 也可以用id替代
7.mysql -u root -p 然后直接输入密码即可 密码是在运行时设置的
use mysql
8.grant all privileges on *.* to ‘root’@’%’ ; 给用于授予权限
GRANTALLPRIVILEGESON *.* ‘root’@’%’ identified by ‘123123’ WITHGRANTOPTION; 这是网上流传较多的写法。实际上会报错的。
9.flush privileges; 刷新权限
10.登录
11
Mysql远程连接报错:authentication plugin caching_sha2
mysql 8.0 默认使用 caching_sha2_password 身份验证机制 —— 从原来的 mysql_native_password 更改为 caching_sha2_password。
从 5.7 升级 8.0 版本的不会改变现有用户的身份验证方法,但新用户会默认使用新的 caching_sha2_password 。
客户端不支持新的加密方式。
方法之一,修改用户的密码和加密方式
ALTER USER ‘root’@’%‘ IDENTIFIED WITH mysql_native_password BY ‘密码’;
要同赋予用户权限时相同。 若是localhost就同上。%也是如此
mysql8.*的新特性 caching_sha2_password 密码加密方式
以前版本的mysql密码加密使用的是 mysql_native_password 新添加的用户密码默认使用的 caching_sha2_password 如果在以前mysql基础上升级的 就得用户使用的密码加密使用的是 mysql_native_password 如果使用以前的密码加密方式,就修改文件 /etc/my.cnf
数据库时区问题:
链接数据库时serverTimezone=UTC这个参数出的问题
只要改成serverTimezone=Asia/Shanghai就OK了!
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/128389.html原文链接:https://javaforall.cn
边栏推荐
- Leetcode daily question (2196. create binary tree from descriptions)
- Automatic light sensing arm lamp touch chip-dlt8sa15b-jericho
- Margin calculation
- 2020-12-07
- [error prone points of C language] Part 4: detailed rules for storing structures in memory
- LeetCode每日一题(2196. Create Binary Tree From Descriptions)
- Intrinsic value and time value of options
- How does the vditor renderer achieve server-side rendering (SSR)?
- JS method of splitting strings
- Parent and child of treeselect
猜你喜欢

How to design a second kill system?

Jetpack Compose 完全脱离 View 系统了吗?

MySQL practice -- master-slave replication

Margin calculation

Single option trading and cross trade

Form for real-time custom verification

One track education, PHP training, unity of knowledge and practice, popular

How to use databricks for data analysis on tidb cloud | tidb cloud User Guide

Machine learning Basics - decision tree-12

RGB game atmosphere light touch chip-dlt8s04a-jericho
随机推荐
Bear market spread portfolio
Leetcode 笔记 566. 重塑矩阵
Leetcode · daily question · 1331. array sequence number conversion · discretization
Jetpack 全家桶之 LiveData 使用及源码篇
[报错]使用ssh登陆到另一台机器后,发现主机名还是自己|无法访问yarn8088
Aragon创建DAO polygon BSC测试网
The form select in antd is received before it is selected
2020-12-07
Protective bearish strategy
Interview must ask, focus! Tell me about the Android application startup process and its source code?
Remove the plug-in of category in WordPress link
企业数字化本质
基于深度学习的超分辨率重建
leetcode-136.只出现一次的数字
SSM框架网上书城全套
2020-12-27
[matlab] IIR filter
10、 Kubernetes scheduling principle
Full disclosure! Huawei cloud distributed cloud native technology and Practice
Definition of option basis