[英]MySQL Running SQL Script error - [WinError 32] The process cannot access the file because it is being used by another process:
I am getting an error while running a SQL script to load data.运行 SQL 脚本加载数据时出现错误。 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.我曾多次尝试卸载和安装 MySQL,但没有任何帮助。
I faced the same issues while trying to run a MySQL script.我在尝试运行 MySQL 脚本时遇到了同样的问题。 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.
我无法运行脚本,但是,我找到了一种解决方法,而不是运行脚本,而是尝试打开它并在查询编辑器中运行它。
The sounds like you already had tried that script execution before and stopped it without stopping the mysqld process.听起来您之前已经尝试过执行该脚本并在不停止 mysqld 进程的情况下停止了它。 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.尝试删除该文件并检查您不想要的所有 MySQL 进程是否已停止。 Then try again.
然后再试一次。
Just downgrade your MySQL workbench version.只需降级您的 MySQL 工作台版本即可。 In my case I downgraded the version from 8.0.25 to 8.0.20.
就我而言,我将版本从 8.0.25 降级到 8.0.20。
It seems the actual issue is not related to MySQL itself, but to MySQL Workbench.似乎实际问题与 MySQL 本身无关,而是与 MySQL Workbench 相关。
The error you're seeing is a generic error coming from Windows itself, not from MySQL.您看到的错误是来自 Windows 本身的一般错误,而不是来自 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.
目前尚不清楚您是如何运行 MySQL 的,例如它是在您的本地主机中、在 Docker 环境中还是在远程服务器中。
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).
我的猜测是 MySQL 不会将临时文件写入我们看到的用户文件夹(使用您的用户名 Pratik)。
On Windows, MySQL checks in order the values of the TMPDIR, TEMP, and TMP environment variables.
在 Windows 上,MySQL 按顺序检查 TMPDIR、TEMP 和 TMP 环境变量的值。 For the first one found to be set, MySQL uses it and does not check those remaining.
对于发现设置的第一个,MySQL 使用它并且不检查剩余的那些。 If none of TMPDIR, TEMP, or TMP are set, MySQL uses the Windows system default, which is usually C:\windows\temp.
如果 TMPDIR、TEMP 或 TMP 均未设置,则 MySQL 使用 Windows 系统默认值,通常为 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.您可以做的是更改您的 MySQL 配置,使其使用您将设置的特定临时路径,重新启动 MySQL 并重试运行查询。 If you see the error contains your new temporary path you've isolated the issue, it is indeed a MySQL problem.
如果您看到错误包含您已隔离问题的新临时路径,则确实是 MySQL 问题。 If you keep seeing this path you've isolated the issue to MySQL WorkBench.
如果您一直看到此路径,则您已将问题隔离到 MySQL WorkBench。
An alternative approach would be to run the same query from another MySQL client, for example the command-line client mysql
;另一种方法是从另一个 MySQL 客户端运行相同的查询,例如命令行客户端
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.可能更简单的方法是使用另一个 MySQL 客户端 dBeaver 尝试查询,并使用它将问题隔离到 MySQL 服务器本身或 MySQL WorkBench。
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.这是 MySQL 升级版本的常见问题,尝试使用 Open Script 而不是 Run Script,这似乎可以解决问题。
Thank you, Akeem Ayinla.谢谢你,阿基姆·艾因拉。 "Run SQL script will not work, " Open SQL script or "Open Recent" will work
“运行 SQL 脚本将不起作用,”打开 SQL 脚本或“打开最近”将起作用
I've found that it was already reported in the official bug tracker: https://bugs.mysql.com/bug.php?id=104841 .我发现它已经在官方错误跟踪器中报告: https://bugs.mysql.com/bug.php?id=10484 I've just checked, and it's still present in MySQL Workbench 8.0.30.
我刚刚检查过,它仍然存在于 MySQL Workbench 8.0.30 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.