【发布时间】:2018-09-25 16:26:21
【问题描述】:
我想将我的 mysql 数据库存储在外部硬盘上。现在,数据位于默认数据目录/usr/local/var/mysql/,因为我已经通过自制软件安装了 mysql。
为了更改数据目录,我修改了以下文件中的数据目录条目:/usr/local/Cellar/mysql/8.0.12/homebrew.mxcl.mysql.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.mysql</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/mysql/bin/mysqld_safe</string>
<string>--datadir=/Volumes/EXTHD/mysql</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/usr/local/var/mysql</string>
</dict>
</plist>
不幸的是,这并没有改变任何东西。我还使用该 datadir 条目创建了文件/etc/my.cnf。没有成功。
我还需要更改哪些内容才能将数据移动到外部硬盘驱动器?
【问题讨论】:
-
使用 homebrew install ,您可能会在
/usr/local/etc/my.cnf找到配置。编辑它,然后重新启动 mysqld -
此文件不存在。
-
没有自制软件的安装和手动创建文件
/etc/my.cnf只需[mysqld]下面的条目datadir=/myPath/就可以了。