当前位置: 首页 > news >正文

实践环境-docker安装mysql8.0.40步骤

一、docker安装mysql 8.0.40版本

1、检索镜像版本
docker search mysql:8.0.40
NAME                             DESCRIPTION                                      STARS     OFFICIAL
mysql                            MySQL is a widely used, open-source relation…   15542     [OK]
circleci/mysql                   MySQL is a widely used, open-source relation…   30
bitnami/mysql                    Bitnami container image for MySQL                122
cimg/mysql                                                                        3
bitnamicharts/mysql              Bitnami Helm chart for MySQL                     0
zabbix/zabbix-web-nginx-mysql    Zabbix frontend based on Nginx web-server wi…   262
ubuntu/mysql                     MySQL open source fast, stable, multi-thread…   66
zabbix/zabbix-server-mysql       Zabbix Server with MySQL database support        417
zabbix/zabbix-proxy-mysql        Zabbix proxy with MySQL database support         46
airbyte/source-mysql                                                              0
zabbix/zabbix-web-apache-mysql   Zabbix frontend based on Apache web-server w…   73
rapidfort/mysql                  RapidFort optimized, hardened image for MySQL    26
bitnami/mysqld-exporter          Bitnami container image for MySQL Server Exp…   7
newrelic/k8s-nri-mysql           New Relic Infrastructure MySQL Integration (…   0
databack/mysql-backup            Back up mysql databases to... anywhere!          123
elestio/mysql                    Mysql, verified and packaged by Elestio          1
google/mysql                     MySQL server for Google Compute Engine           25
rapidfort/mysql8-ib              RapidFort optimized, hardened image for MySQ…   9
zabbix/zabbix-build-mysql        Zabbix build base (MySQL)                        5
drupalci/mysql-5.5               https://www.drupal.org/project/drupalci          3
drupalci/mysql-5.7               https://www.drupal.org/project/drupalci          0
docksal/mysql                    MySQL service images for Docksal - https://d…   0
drupalci/mysql-8                 https://www.drupal.org/project/drupalci          0
hashicorp/mysql-portworx-demo                                                     0
jumpserver/mysql
2、拉取镜像
docker pull mysql:8.0.40
8.0.40: Pulling from library/mysql
2c0a233485c3: Already exists
b746eccf8a0b: Pull complete
570d30cf82c5: Pull complete
c7d84c48f09d: Pull complete
e9ecf1ccdd2a: Pull complete
6331406986f7: Pull complete
f93598758d10: Pull complete
6c136cb242f2: Pull complete
d255d476cd34: Pull complete
dbfe60d9fe24: Pull complete
9cb9659be67b: Pull complete
Digest: sha256:d58ac93387f644e4e040c636b8f50494e78e5afc27ca0a87348b2f577da2b7ff
Status: Downloaded newer image for mysql:8.0.40
docker.io/library/mysql:8.0.40

3、启动docker


#启动docker,默认启动,root默认密码123456
3、docker run -itd --name mysql8  -p 3066:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:8.0.40
4a98c39b22da88bb36134e8aea5058551c8bcaa113767565d6eb75ff8c993a2c#4 查看docker启动状态
4、docker ps
CONTAINER ID   IMAGE          COMMAND                   CREATED         STATUS         PORTS                               NAMES
4a98c39b22da   mysql:8.0.40   "docker-entrypoint.s…"   5 seconds ago   Up 5 seconds   33060/tcp, 0.0.0.0:3066->3306/tcp   mysql8

二、创建数据库及授权用户

#5 登录docker,执行基本命令
docker exec -it mysql8 /bin/bash
docker exec -it mysql8 /bin/bash
bash-5.1# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.40 MySQL Community Server - GPL
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
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 创建新数据库步骤
#6.1 查看当前有哪些数据库
mysql> SHOW DATABASE;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATABASE' at line 1
mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)#6.2 创建新数据库:demo
mysql> CREATE DATABASE demo DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
Query OK, 1 row affected, 2 warnings (0.00 sec)#6.3 查看是否已经创建成功
mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| demo               |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)#7 创建非root用户,并授权新建数据库demomysql> CREATE DATABASE demo DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
Query OK, 1 row affected, 2 warnings (0.00 sec)mysql> CREATE USER 'demo'@'%' IDENTIFIED BY 'demo@1234';
Query OK, 0 rows affected (0.00 sec)mysql> GRANT ALL PRIVILEGES ON demo.* TO 'demo'@'%';
Query OK, 0 rows affected (0.00 sec)mysql>  FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)#8 用户demo用户登录验证
bash-5.1# mysql -udemo -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.40 MySQL Community Server - GPL
Copyright (c) 2000, 2024, Oracle and/or its affiliates.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> show databases;
+--------------------+
| Database           |
+--------------------+
| demo               |
| information_schema |
| performance_schema |
+--------------------+
3 rows in set (0.01 sec)

三、FAQ

3.1 用DBeaver 连接数据库的时候出现Public Key Retrieval is not allowed

    连接设置 - 驱动属性 ,找到allowPublicKeyRetrieval,把allowPublicKeyRetrieval的值设为 切换为 TRUE 即可。
http://www.lryc.cn/news/505998.html

相关文章:

  • 边缘智能创新应用大赛获奖作品系列一:智能边缘计算✖软硬件一体化,开启全场景效能革命新征程
  • 决策树的生成与剪枝
  • 蓝桥杯算法训练 黑色星期五
  • MySQL存储引擎-存储结构
  • 理解torch函数bmm
  • 2024 年的科技趋势
  • win服务器的架设、windows server 2012 R2 系统的下载与安装使用
  • leetcode45.跳跃游戏II
  • 边缘智能创新应用大赛获奖作品系列三:边缘智能强力驱动,机器人天团花式整活赋能千行百业
  • 基于语义的NLP任务去重:大语言模型应用与实践
  • 使用阿里云Certbot-DNS-Aliyun插件自动获取并更新免费SSL泛域名(通配符)证书
  • Node.js安装配置+Vue环境配置+创建一个VUE项目
  • “TA”说|表数据备份还原:SQLark 百灵连接助力项目部署验收
  • 【FFmpeg】解封装 ① ( 封装与解封装流程 | 解封装函数简介 | 查找码流标号和码流参数信息 | 使用 MediaInfo 分析视频文件 )
  • Spring Boot 集成 MyBatis 全面讲解
  • C语言小练习-打印字母倒三角
  • Linux -- 线程控制相关的函数
  • 基于quasar,只选择年度与月份的组件
  • 健康养生:拥抱生活的艺术
  • 注意力机制+时空特征融合!组合模型集成学习预测!LSTM-Attention-Adaboost多变量时序预测
  • uniapp 微信小程序 均分数据展示
  • Nacos 3.0 考虑升级到 Spring Boot 3 + JDK 17 了!
  • 跟沐神学读论文-论文阅读管理
  • Python 参数配置使用 XML 文件的教程 || Python打包 || 模型部署
  • [SV]如何在UVM环境中使用C Model
  • 十大开源的Cursor AI替代方案
  • 相机光学(四十六)——镜头马达(VCM)控制策略模式
  • 专业140+总分410+浙江大学842信号系统与数字电路考研经验浙大电子信息与通信工程,真题,大纲,参考书。
  • 了解ARM的千兆以太网——RK3588
  • JavaFX使用jfoenix的UI控件