简体   繁体   English

MySQL 运行 SQL 脚本错误 - [WinError 32] 进程无法访问该文件,因为它正被另一个进程使用:

[英]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 中。

Work Around变通
Do not try to open the SQL file from this tool bar:不要尝试从此工具栏打开 SQL 文件:

在此处输入图像描述

Go to Server > Data Import: Go 到服务器 > 数据导入:

在此处输入图像描述

  • select import from self-contained file select 从独立文件导入
  • select your target schema select 你的目标架构
  • then start import (bottom right btn)然后开始导入(右下btn)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 执行 SQL 脚本时出错; 该进程无法访问该文件,因为它正被另一个进程使用:'C:\\Users\\......\....cnf' - Error executing SQL script; The process cannot access the file because it is being used by another process:'C:\\Users\\......\....cnf' FileStream错误-进程无法访问文件…由另一个进程使用 - FileStream error - The process cannot access the file…used by another process mysql.service失败,因为控制进程退出并显示错误代码 - mysql.service failed because the control process exited with error code Ruby脚本来处理SQL文件中的每一行 - Ruby Script to Process each line in an SQL file mysql进程无法停止 - mysql process cannot be stopped 如何处理 MySQL bat 文件中的错误? - How to process with error in MySQL bat file? “错误! 找不到MySQL服务器PID文件!”,但是3d端口上正在运行mysqld进程吗? - “ERROR! MySQL server PID file could not be found!”, yet a mysqld process is running on port 3306? mysql脚本文件(.sql)运行问题 - mysql script file (.sql) running problem 循环中的mysql进程无法停止 - mysql process in loop cannot be stopped 出现错误:mysql.service 失败,因为控制进程以错误代码退出。 安装 docker 后 - Getting Error: mysql.service failed because the control process exited with error code. after installing docker
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM