Re: DB query failed: SQLSTATE[HY000]: General error: 1 Can't create/write to file '/var/tmp/#sql_381
Hello R K Solanki,
I hope you are doing well!
The error message above can be due to two reasons, i.e., /tmp partition has run out of space, and the file couldn't be created for some reason. Secondly, the mysqld process cannot write to that directory because of permission problems.
You can try the steps below to fix this issue,
1. Check Mysql config: my.cnf
cat /etc/my.cnf | grep tmpdir
2. add tmpdir=/tmp to my.cnf under [mysqld]
3. restart web/app and mysql server
You must set the MySQL config variable tmpdir to a directory on another disk partition with more space.
Furthermore, you will have to grant the /tmp folder as 777 permission. You can use the following command to grant permission chmod -R 777 /tmp
You can also restart the mysqld service with the following command, systemctl start mysqld.service
Now, on restarting the service, mysqld works because it starts everything over again with a fresh start, with a brand new private /tmp directory.
In order to solve the issue, you also have to configure /bin/systemd-tmpfiles.
The MySQL DB service will be up and running when you give permission to temp tables, clear the inodes, and restart the mysqld service.