在 MySQL 管理员中更改数据库文件位置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/126406/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 12:05:34  来源:igfitidea点击:

Change database files location in MySQL administrator?

mysql

提问by vuthaKH

I would like to change the database files location of MySQL administrator to another drive of my computer. (I run Windows XP SP2 and MySQL Administrator 1.2.8.)

我想将 MySQL 管理员的数据库文件位置更改为我计算机的另一个驱动器。(我运行 Windows XP SP2 和 MySQL Administrator 1.2.8。)

--Under the startup variable --> General Parameters --> I changed Data directory:from C:/Program Files/MySQL/MySQL Server 5.0/datato D:/....., but after I stopped the service and restarted it, the following error appeared:

--Under启动变量- >常规参数- >我改变Data directory:C:/Program Files/MySQL/MySQL Server 5.0/dataD:/.....,但后,我停止了服务,并重新启动它,下面的错误出现:

Could not re-connect to the MySQL Server.
Server could not be started.

Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

Has anyone else had this problem?

有没有其他人有这个问题?

回答by Armin Ronacher

Normally it works like this:

通常它是这样工作的:

  1. shut down MySQL
  2. change the [mysqld]and [mysqld_safe]datadirvariable in the MySQL configuration
  3. change the basedirvariable in the same section.
  4. move the location over
  5. restart MySQL
  1. 关闭 MySQL
  2. 更改MySQL 配置中的[mysqld]and[mysqld_safe]datadir变量
  3. 更改basedir同一部分中的变量。
  4. 移动位置
  5. 重启 MySQL

If that doesn't work I have no idea. On linux you can try to move the socket to a new location too, but that shouldn't affect windows. Alternatively you can use a symbolic link on *nix what most people do I guess.

如果那不起作用,我不知道。在 linux 上,您也可以尝试将套接字移动到新位置,但这不应该影响 Windows。或者,您可以在 *nix 上使用符号链接,我猜大多数人都会这样做。

回答by ajcw

In Windows

在 Windows 中

  1. Navigate to C:\Program Files\MySQL\MySQL Server 5.4\and locate the my.inifile
  2. Find the SERVER SECTION and go to approx line 76 and modify the datadirline to where you want your MySQL application data to be stored
  3. Now navigate to C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.4\data\and copy and paste the mysql folder into your new location.
  4. Restart the MySQL Server in Control Panel > Administrative Tools > Service
  1. 导航C:\Program Files\MySQL\MySQL Server 5.4\并找到该my.ini文件
  2. 找到 SERVER SECTION 并转到大约第 76 行并将datadir行修改为您希望存储 MySQL 应用程序数据的位置
  3. 现在导航到C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.4\data\mysql 文件夹并将其复制并粘贴到您的新位置。
  4. 控制面板 > 管理工具 > 服务中重启 MySQL 服务器

回答by BMZ

Make sure you give the Network Service Full permissions in the security tab of Windows Explorer options. If the server can't read/write etc. to the selected folder the service will either not start or it will attempt a start and shut right down.

确保在 Windows 资源管理器选项的安全选项卡中授予网络服务完全权限。如果服务器无法对所选文件夹进行读/写等操作,则该服务将不会启动,或者会尝试启动并立即关闭。

回答by Silver Dragon

You also have to manually modify mysql's configuration (usually my.conf)

您还必须手动修改 mysql 的配置(通常是 my.conf)

回答by Daniel Schneller

MySQL Administrator cannot be used for tasks like this. It is merely a tool for looking at MySQL servers, despite its name. Relocating data is described in many MySQL tutorials and in the manual IIRC. But basically it's just moving the data to a new location while the server is shut down and then correcting the paths in the servers config file. After that you should be able to restart the server and connect MySQL Administrator to it.

MySQL Administrator 不能用于此类任务。尽管它的名字是这样,但它只是一个查看 MySQL 服务器的工具。许多 MySQL 教程和手册 IIRC 中描述了重定位数据。但基本上它只是在服务器关闭时将数据移动到新位置,然后更正服务器配置文件中的路径。之后,您应该能够重新启动服务器并将 MySQL Administrator 连接到它。