在 my.ini 中的 [mysqld] 段设置 mysql basedir 和 datadir,如下:
#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server/"
#Path to the database root
datadir="C:/Program Files/MySQL/MySQL Server/data/"
经常我们用bat文件获取该目录并添加至my.ini文件时,所得的效果是这样的:
#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:Program FilesMySQLMySQL Server"
#Path to the database root
datadir="C:Program FilesMySQLMySQL Serverdata"
一般情况下,这样添加的路径是没有问题的,但是如果路径中包含字母 b 开头的文件夹名时,会导致mysql服务启动不了,可能因为 正好是一个转义字符,所以在设置路径时应该使用 "/" 而不是 "".