当前位置:网站首页>K8s, docker compose install MySQL 8.0.18
K8s, docker compose install MySQL 8.0.18
2022-06-25 12:21:00 【lihongbao80】
One 、k8s install mysql 8.0.18
1、 Installation services
vim mysql-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-deploy
labels:
name: mysql-deploy-label
namespace: paas-db
spec:
replicas: 1
selector:
matchLabels:
name: mysql-pod
template:
metadata:
labels:
name: mysql-pod
spec:
nodeSelector:
mysql: "true"
terminationGracePeriodSeconds: 30 #k8s correct 、 Gracefully close the app , Waiting time 30 second
containers:
- name: mysql-container
image: mysql:8.0.18
imagePullPolicy: IfNotPresent
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: "123456"
- name: TIME_ZONE
value: Asia/Shanghai
volumeMounts:
- name: mysql-volume
mountPath: /var/lib/mysql
#- name: mysql-conf
# mountPath: /etc/mysql/conf.d
- name: date-config
mountPath: /etc/localtime
volumes:
- name: mysql-volume
hostPath:
path: /home/k8s-1.19.2/paas-db/mysql/volume
#- name: mysql-conf
# hostPath:
# path: /home/k8s-1.19.2/paas-db/mysql/config/conf.d
- name: date-config
hostPath:
path: /etc/localtime
vim mysql-service.yaml
#Service
apiVersion: v1
kind: Service
metadata:
name: mysql-service
labels:
name: mysql-service-label
namespace: paas-db
spec:
type: NodePort
ports:
- port: 3306
protocol: TCP
targetPort: 3306
name: http
nodePort: 30306
selector:
name: mysql-pod
2、 Copy the configuration file from the container on the server where the data is landed
[[email protected] config]# docker cp c35f42eb5c0b:/etc/mysql/conf.d .
[[email protected] config]# ll
Total usage 0
drwxrwxr-x 2 root root 41 12 month 29 2019 conf.d
3、 Get rid of deployment The profile comment for references an external profile
4、mysql8 In previous versions, the encryption rule was mysql_native_password, And in the mysql8 after , The encryption rule is caching_sha2_password, There are two ways to solve the problem , One is upgrading navicat drive , One is the mysql The encryption rule of user login password is restored to mysql_native_password
The phenomenon :
Processing mode :
1、 install mysql Client access mysql
mysql -h 192.168.180.37 -P 30306 -uroot -p123456
Or enter mysql Containers , Log in to the container mysql
[[email protected] config]# docker exec -it c35f42eb5c0b bash
[email protected]-deploy-69978db9c8-jz6fc:/# mysql -h 127.0.0.1 -uroot -p123456
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 11
Server version: 8.0.18 MySQL Community Server - GPL
Copyright (c) 2000, 2019, 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>
2、 Yes mysql Set the following .
MySQL [(none)]> alter user 'root'@'%' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.01 sec)
MySQL [(none)]>
Two 、docker-compose install mysql 8.0.18
version: '3'
services:
db:
# structure mysql Mirror image
image: mysql:8.0.18
container_name: mysql # Container name
command:
--default-authentication-plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
restart: always
environment:
MYSQL_ROOT_PASSWORD: root #root Administrator user password
ports:
- '3306:3306' #host The physical direct mapping port is 6606
volumes:
#mysql Mount the database to host Physical machine directory
- "./mysql_data:/var/lib/mysql"
# The configuration directory of the container is mounted to host Physical machine directory
- "./conf:/etc/mysql/conf.d"
边栏推荐
- [oceanbase] Introduction to oceanbase and its comparison with MySQL
- ROS 笔记(06)— 话题消息的定义和使用
- How to open an account for trading futures Shanghai nickel products online
- Le détour d'un ingénieur en matériel
- Recyclerview scrolls to the specified location
- 一个硬件工程师走过的弯路
- Redis雪崩、穿透和击穿是什么?
- Kotlin基础
- Why can't you Ping the website but you can access it?
- R language uses the scale function to scale the input data of neural network to the minimum and maximum, scale the data to between 0 and 1, and divide the data set into training set and test set
猜你喜欢

SQL server saves binary fields to disk file

What are redis avalanche, penetration and breakdown?

What is principal component analysis? Dimension reduction of classical case analysis variables

plt.gca()画框及打标签

黑马畅购商城---3.商品管理
![[oceanbase] Introduction to oceanbase and its comparison with MySQL](/img/1c/bd2bcddb7af4647407d2bc351f5f5d.png)
[oceanbase] Introduction to oceanbase and its comparison with MySQL

Actual combat summary of Youpin e-commerce 3.0 micro Service Mall project

黑马畅购商城---2.分布式文件存储FastDFS

Time series analysis - how to use unit root test (ADF) correctly?

19、wpf之事件转命令实现MVVM架构
随机推荐
Flutter common commands and problems
Time series analysis - how to use unit root test (ADF) correctly?
机器学习自学成才的十条戒律
Startups must survive
VFP develops a official account to receive coupons, and users will jump to various target pages after registration, and a set of standard processes will be sent to you
Old ou, a fox friend, has had a headache all day. The VFP format is always wrong when it is converted to JSON format. It is actually caused by disordered code
Dark horse shopping mall ---2 Distributed file storage fastdfs
How far is it from the DBF of VFP to the web salary query system?
一篇文章讲清楚MySQL的聚簇/联合/覆盖索引、回表、索引下推
揭秘GaussDB(for Redis):全面對比Codis
Why can't the form be closed? The magic of revealing VFP object references
ARM V7 ldr str 内存访问
做自媒体视频需要怎么做才能年收入一百万?
R语言使用scale函数对神经网络的输入数据进行最小最大缩放、把数据缩放到0到1之间、并划分数据集为训练集和测试集
Cesium building loading (with height)
How to use SPSS to do grey correlation analysis? Quick grasp of hand-to-hand Teaching
2020最新最全IT学习线路
. Using factory mode in net core
Actual combat summary of Youpin e-commerce 3.0 micro Service Mall project
Linear regression of common mathematical modeling models for College Students