MySQL Running SQL Script error - [WinError 32] The process cannot access the file because it is being used by another process:
Asked Answered
H

7

8

Error Image

I am getting an error while running a SQL script to load data. Error is pasted below:

Preparing...
[WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\PRATIK~1\\AppData\\Local\\Temp\\tmpf75l0wi5.cnf'

I have tried uninstalling and installing MySQL several times but nothing is helping.

Heyes answered 26/1, 2021 at 20:1 Comment(1)
What does the script do? Where does tmpf75l0wi5.cnf come from? (It does not sound like a MySQL file.) What invoked the script?Flummery
C
4

I faced the same issues while trying to run a MySQL script. I tried to find the process in the temp folder and removed it and tried again but the process seems to start again and appears in the temp folder. I could not run the script, however, I found a workaround, instead of running the script try to open it and run it in the query editor.

Clinker answered 17/4, 2021 at 13:21 Comment(1)
Its not working I tried running script , but it just create empty fields with no values inside.Intort
S
4

Work Around
Do not try to open the SQL file from this tool bar:

enter image description here

Go to Server > Data Import:

enter image description here

  • select import from self-contained file
  • select your target schema
  • then start import (bottom right btn)

enter image description here

Sexagenarian answered 10/1, 2023 at 10:23 Comment(0)
I
2

Just downgrade your MySQL workbench version. In my case I downgraded the version from 8.0.25 to 8.0.20.

Intort answered 27/6, 2021 at 5:12 Comment(5)
i still would like to know what scripts you are running to get that message and if it is deterministic report it.Goalie
Its a simple sql script from employees database Here's link : employees.sqlIntort
the zip in the text is not longer a, so i can reproduce the import errorGoalie
So the problem in your file is that source isn't allowed in workbench, so automatically installing isn't possible anymore, install all files by handGoalie
Thank you, the downgrade solved it.Exegete
W
1

The sounds like you already had tried that script execution before and stopped it without stopping the mysqld process. So this process (which does the actual import) still holds a file lock on the temporary config file.

Try removing that file and check that all MySQL processes that you don't want are stopped. Then try again.

Worthy answered 28/1, 2021 at 8:25 Comment(0)
E
1

It seems the actual issue is not related to MySQL itself, but to MySQL Workbench.

The error you're seeing is a generic error coming from Windows itself, not from MySQL. It's unclear how you're running MySQL, for example is it in your localhost, in a Docker environment, or in a remote server.

It seems clear that at least two processes are trying to get an exclusive lock on that temporary file. My guess is that MySQL won't write temporary files to the user folder we're seeing (with your username Pratik).

On Windows, MySQL checks in order the values of the TMPDIR, TEMP, and TMP environment variables. For the first one found to be set, MySQL uses it and does not check those remaining. If none of TMPDIR, TEMP, or TMP are set, MySQL uses the Windows system default, which is usually C:\windows\temp.

Something you can do is to change your MySQL configuration so it uses a specific Temporary path you'll set, restart MySQL and retry running the query. If you see the error contains your new temporary path you've isolated the issue, it is indeed a MySQL problem. If you keep seeing this path you've isolated the issue to MySQL WorkBench.

An alternative approach would be to run the same query from another MySQL client, for example the command-line client mysql; and see if you're getting the same error.

Probably the simpler approach would be to try the queries with dBeaver, another MySQL client, and use that to isolate the issue to either the MySQL server itself or MySQL WorkBench.

Elihu answered 2/7, 2021 at 16:56 Comment(0)
R
1

This is a common issue for the upgraded version of MySQL, Try using Open Script instead of Run Script and that seems to clear up the issue.

Reredos answered 10/11, 2021 at 20:48 Comment(0)
H
0

I've found that it was already reported in the official bug tracker: https://bugs.mysql.com/bug.php?id=104841. I've just checked, and it's still present in MySQL Workbench 8.0.30.

Honesty answered 21/8, 2022 at 18:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.