[TOC]
docker logs mysql查看日志
# 情况一:Error while setting value xxx to 'sql_mode'
~~~
ERROR: mysqld failed while attempting to check config
command was: "mysqld --verbose --help"
2020-03-13T09:35:44.881652Z 0 [ERROR] [MY-000077] [Server] /usr/sbin/mysqld: Error while setting value 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' to 'sql_mode'.
~~~
**修改my.cnf**
MYSQL8以上已经取消了NO\_AUTO\_CREATE\_USER,sql\_mode中不能包含这个。
~~~java
sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUT
~~~
# 情况二: Error on realpath() on ‘/var/lib/mysql-files’ (Error 2 - No such file or directory
```
2020-08-05T10:18:34.282304Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
```
从报错内容可以看出,是/var/lib/mysql-files目录不存在导致(容器内的目录)。
secure-file-priv参数是用来限制LOAD DATA, SELECT ... OUTFILE, and LOAD\_FILE()传到哪个指定目录的。
* ure\_file\_priv的值为null ,表示限制mysqld 不允许导入|导出
* 当secure\_file\_priv的值为/tmp/ ,表示限制mysqld 的导入|导出只能发生在/tmp/目录下
* 当secure\_file\_priv的值没有具体值时,表示不对mysqld 的导入|导出做限制
如何查看secure-file-priv参数的值:
~~~
show global variables like '%secure%';
~~~
windows下:修改my.ini 在\[mysqld\]内加入secure\_file\_priv=/var/lib/mysql
linux下:修改my.cnf 在\[mysqld\]内加入secure\_file\_priv=/var/lib/mysql