0

I have a PHP project which is working with MariaDB/MySQL on a DirectAdmin machine.
It's a month that I receive this error while running a certain page in my application as below:

PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000]: General error: 1 Can't create/write to file '/tmp/#sql...

When I restart the mysqld service on the server, everything goes well! I am sure that there is not any issue on the disk space. This is the current server status:

[root@srv1 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G  880K  3.9G   1% /dev/shm
tmpfs           3.9G  390M  3.5G  10% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/vda1        42G   22G   18G  57% /
tmpfs           783M     0  783M   0% /run/user/0

What is your idea to solve this issue?

Mohammad Saberi
  • 12,864
  • 27
  • 75
  • 127
  • This sort of thing is seen when a query consumes all of the temporary file space allotted to the database engine. You’ll want to check to see if you have hard limits on the buffer sizes used by the database and examine the SQL query (or queries) that exhaust that memory. – matigo May 29 '21 at 05:48
  • @matigo do you know any special parameter in configurations which I can search for it? – Mohammad Saberi May 29 '21 at 07:52

1 Answers1

0

Your problem is that you do not have identified the temporary ones in the database, the simplest way is to delete the temporary ones from the entire system that are 14 days old

find /tmp -type f -mtime +14 -exec rm {} \;
find /var/tmp -type f -mtime +14 -exec rm {} \;

Check the size and clean package cache

du -sh /var/cache/apt/
sudo apt-get clean
service mysqld restart

there is little information for a very recurring problem