Mysql之Can't create/write to file '/tmp/#sql_2b6d_0.MY 得问题-yellowcong

Can't create/write to file 这个问题,是由于mysql默认配置得缓存目录默认是/tmp导致得,解决方案就是手动创建一个目录,设置好权限后,修改配置/etc/my.cnf ,添加tmpdir=/data/mysql_data/tmp ,设定我们指定的缓存目录,然后重启mysql即可解决问题。

问题

Caused by: java.sql.SQLException: Can't create/write to file '/tmp/#sql_2b6d_0.MYI' (Errcode: 13 - Permission denied)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074) ~[mysql-connector-java-5.1.21.jar:?]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4074) ~[mysql-connector-java-5.1.21.jar:?]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4006) ~[mysql-connector-java-5.1.21.jar:?]
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2468) ~[mysql-connector-java-5.1.21.jar:?]
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629) ~[mysql-connector-java-5.1.21.jar:?]

Mysql之Can't create/write to file '/tmp/#sql_2b6d_0.MY 得问题-yellowcong_第1张图片

解决办法

Mysql之Can't create/write to file '/tmp/#sql_2b6d_0.MY 得问题-yellowcong_第2张图片
chmod -R mysql:mysql /data/mysql_data/tmp 设定这个缓存目录得权限,然后配置my.cnf,设置tmpdir得目录,并重启mysql 即可

#/etc/my.cnf
tmpdir=/data/mysql_data/tmp

然后执行命令 show variables like '%dir%' ; ,查看设置是否ok,然后就没有那个问题了。
Mysql之Can't create/write to file '/tmp/#sql_2b6d_0.MY 得问题-yellowcong_第3张图片

参考文章

https://blog.csdn.net/liuxiao723846/article/details/37816987

你可能感兴趣的:(mysql)