当前位置:网站首页>Creation of kubernetes mysql8

Creation of kubernetes mysql8

2022-07-07 20:08:00 Li Weilun

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql1
  namespace: default
  labels:
    app: mysql1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql1
  template:
    metadata:
      labels:
        app: mysql1
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: ip
                operator: In
                values:
                - 172.16.12.104
      containers:
      - name: mysql1
        envFrom:
        - secretRef:
            name: mysql1
        image: mysql:8
        args:
          - "--lower_case_table_names=1"
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 3306
          name: 3306tcp
          protocol: TCP
        volumeMounts:
        - mountPath: /var/lib/mysql
          name: mysql1data
      volumes:
      - hostPath:
          path: /opt/mysql1/data/
          type: DirectoryOrCreate
        name: mysql1data
      restartPolicy: Always

mysql8 There's an important feature , Case sensitivity can only be completed when the database is initialized , So we're going to be here args Join in –lower_case_table_names=1, That is, the case is not sensitive

Create user ,mysql8 You need to create a user before you can assign permissions

use mysql;create user 'szxy_test'@'%' identified by 'Liweilun1208.';

If you forget when creating users with mysql_native_password
Log in with this user and report authentication plugin 'caching_sha2_password' cannot be loaded;

alter user 'szxy_test'@'%' identified with mysql_native_password by 'Liweilun1208.';

Assign permissions

grant all privileges on *.* to 'szxy_test'@'%' with grant option;
原网站

版权声明
本文为[Li Weilun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/07/202207071805006855.html