The other day we began to encounter weird and random errors on small and innocent queries that shouldn’t give any errors at all. It all lead to one of our most basic health checks failing for no apparent reason.
The first clue that popped into our minds was related to case-sensitivity, since the failing check was looking for the column names of the only table in the schema with UPPER CASE name. This symptom was especially weird since all of this was happening on MySQL setups running on Windows, and so we’re not sure if this was being caused by some internal code library, MySQL, or Windows itself.
Since that was the only clue we then had, it seemed obvious that we should start fiddling with the lower_case_table_names system variable. After a couple of restarts, this approach was leading us nowhere, so we finally gave up on it.
Then, we had the brilliant idea of actually executing that statement by hand on the command line to see what happened:
C:pythian>mysql -uXXXX -p XXXX -e "desc TABLE_NAME" Enter password: ***** ERROR 1 (HY000) at line 1: Can't create/write to file 'C:MySQL mp#sql_634_0.MYI' (Errcode: 22) C:pythian>perror 22 OS error code 22: Invalid argument C:pythian>
None of us remembered seeing this one before, so we stared at the monitor for a few moments, not realizing the meaning of this message. I guess our focus on the case-sensitivity was driving us away a from the real cause. So . . . time to check the
my.ini file. Inside it, we found:
This line belongs to a recent configuration change in which the tmpdir has been relocated on some instances. Apparently, we missed a small detail earlier:
t actually gets translated into a tab character when MySQL starts.
We need to change the escape sequence so we get a slash instead of tab. One of the ways we can accomplish this is by changing the line above to:
After that configuration update and a bounce on the DB (
tmpdir is a read-only system variable), we did the same test:
C:pythian>mysql -uXXXX -p XXXX -e "desc TABLE_NAME" Enter password: ***** +---------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+-------------+------+-----+---------+-------+ | col1 | varchar(30) | YES | | NULL | | | col2 | int(11) | YES | | NULL | | +---------+-------------+------+-----+---------+-------+ C:pythianavail>
And there we go. Note that
t is interpreted as the tab character across OS platforms. But, it’s only on MS Windows that it might appear as a filesystem path.
10 Responses to “MySQL: my.ini Gotcha on Windows”
Leave a Reply