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.
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 [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. 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.
chown
command.Additional information can be found in this thread or this .
As mentioned in this Github thread you can disable apparmor for mysql
or use command form this comment . You can also check this thread for more information.
privilaged
optionIt was cover by this SO question
You could also check this similar thread if you are using docker-compose
.
Please let me know if any of those options worked for you or you still have issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.