简体   繁体   English

mysqld:无法读取“/etc/mysql/conf.d/”的目录(OS errno 13 - 权限被拒绝)

[英]mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 13 - Permission denied)

docker-mysql-configmap.yml docker-mysql-configmap.yml

apiVersion: v1
kind: ConfigMap
metadata:
    name: mysql-initdb-config 
data: 
    initdb.sql:
        use mydb;
        create table product(
        id int AUTO_INCREMENT PRIMARY KEY,
        name varchar(20),
        description varchar(100),
        price decimal(8,3) 
        );
            
        create table coupon(
        id int AUTO_INCREMENT PRIMARY KEY,
        code varchar(20) UNIQUE,
        discount decimal(8,3),
        exp_date varchar(100) 
        ); ```

db-mysql-service.yml

```apiVersion: v1
kind: Service
metadata:
    name: docker-mysql
    labels:
        app: docker-mysql
spec:
    selector:
        app: docker-mysql
    
    ports:
        - port: 3306
          targetPort: 3306     
          nodePort: 30287  
    type: NodePort 

        
   ``` >


db-sql-deplymonent.yml

```apiVersion: apps/v1
kind: Deployment
metadata: 
    name: docker-mysql
    labels:
        app: docker-mysql
spec:
    replicas: 1  
    selector:
        matchLabels:
            app: docker-mysql      
    template:
        metadata:
            labels: 
                app: docker-mysql
        spec:
          volumes: 
            - name: mysql-initdb-vol
              configMap:
                name: mysql-initdb-config 
          containers: 
                 - name: docker-mysql
                   image: mysql
                   volumeMounts:
                    - name:  mysql-initdb-vol
                      mountPath: /docker-entrypont-initdb.d
                   
                   
                   env:
                     - name: MYSQL_DATABASE 
                       value: mydb 
                     
                        
                     - name: MYSQL_ROOT_PASSWORD
                       value: norton09   
                     - name: MYSQL_ROOT_HOST
                       value: '%'   
                   



when i checking logs of pod i am getting errors.当我检查 pod 的日志时,出现错误。

2020-09-06 01:10:15+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started. 2020-09-06 01:10:15+00:00 [注意] [入口点]:MySQL Server 8.0.21-1debian10 的入口点脚本已启动。 2020-09-06 01:10:15+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config command was: mysqld --verbose --help mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 13 - Permission denied) mysqld: [ERROR] Fatal error in defaults handling. 2020-09-06 01:10:15+00:00 [错误] [入口点]:mysqld 在尝试检查配置命令时失败:mysqld --verbose --help mysqld:无法读取 '/etc/ 目录mysql/conf.d/' (OS errno 13 - Permission denied) mysqld: [ERROR] 默认处理中的致命错误。 Program aborted!程序中止!

You didn't mention what environment, kubernetes or mysql version are you using but there a few things which might help with this issue.您没有提到您使用的是什么环境、kubernetes 或 mysql 版本,但有一些事情可能有助于解决此问题。

  1. Change access to this file/directory You also didnt mention if you want to check how it works or it will be used in production.更改对这个文件/目录的访问你也没有提到你是否想检查它是如何工作的,或者它将在生产中使用。 If this solution would fit your needs you could change permissions to the file using chown command.如果此解决方案符合您的需求,您可以使用chown命令更改文件的chown

Additional information can be found in this thread or this .可以在此线程此 中找到其他信息。

  1. Disabling apparmor禁用 apparmor

As mentioned in this Github thread you can disable apparmor for mysql or use command form this comment .如此 Github 线程中所述,您可以禁用mysql apparmor 或使用 此评论中的命令。 You can also check this thread for more information.您还可以查看此线程以获取更多信息。

  1. Use privilaged option使用privilaged选项

It was cover by this SO question它被this SO question所覆盖

You could also check this similar thread if you are using docker-compose .如果您正在使用docker-compose您也可以检查这个类似的线程

Please let me know if any of those options worked for you or you still have issue.如果这些选项中的任何一个对您有用,或者您仍然有问题,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM