当前位置:网站首页>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"
边栏推荐
- [on]learning dynamic and hierarchical traffic spatiotemporal features with transformer
- Kotlin study notes
- Kotlin学习笔记
- 做自媒体视频需要怎么做才能年收入一百万?
- 15、wpf之button样式小记
- PyCaret 成功解决无法从‘sklearn.model_selection._search‘导入名称“_check_param_grid”
- Dark horse shopping mall ---3 Commodity management
- VFP a picture processing library, simple and easy to use, free of charge, worth recommending
- Mpai data science platform random forest classification \ explanation of regression parameter adjustment
- 属性分解 GAN 复现 实现可控人物图像合成
猜你喜欢

Redis雪崩、穿透和击穿是什么?
![[论]Learning Dynamic and Hierarchical Traffic Spatiotemporal Features with Transformer](/img/58/d68112a3d019de66150e2f5102f436.png)
[论]Learning Dynamic and Hierarchical Traffic Spatiotemporal Features with Transformer

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

2022年首期Techo Day腾讯技术开放日将于6月28日线上举办

VFP serial port communication is difficult for 9527. Maomao just showed his skill and was defeated by kiss

How far is it from the DBF of VFP to the web salary query system?

Découvrir gaussdb (pour redis): une comparaison complète avec Codis

Database Series: MySQL index optimization summary (comprehensive version)

plt. GCA () picture frame and label
![[regression analysis] understand ridge regression with case teaching](/img/95/91f6f2a018b8d320945b12562492eb.jpg)
[regression analysis] understand ridge regression with case teaching
随机推荐
plt. GCA () picture frame and label
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
VFP uses Kodak controls to control the scanner to solve the problem that the volume of exported files is too large
R language uses GLM function to build Poisson logarithmic linear regression model, processes three-dimensional contingency table data to build saturation model, and poisgof function of epidisplay pack
R语言caTools包进行数据划分、scale函数进行数据缩放、e1071包的naiveBayes函数构建朴素贝叶斯模型
Recyclerview scrolls to the specified location
RecyclerView滚动到指定位置
Use PHP script to view the opened extensions
The dist function of R language calculates the distance between two samples in dataframe data, returns the distance matrix between samples, and specifies the distance calculation method through the me
Dark horse shopping mall ---8 Microservice gateway and JWT token
Arm immediate
设置图片的透明度从左到右渐变
Does sklearex make your sklearn machine learning model training fly fast?
confluence7.4. X upgrade record
Dark horse shopping mall ---2 Distributed file storage fastdfs
Hook technology
MYSQL中对复杂JSON的更新
Arm V7 coprocessor
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
Redis雪崩、穿透和击穿是什么?