日期:2014-06-26  浏览次数:22567 次

把MySQL装在了C:\Program Files\MySQL\MySQL Server 5.0,默认的数据库文件是放在C:\Program Files\MySQL\MySQL Server 5.0\data下。 

但现在在D盘下做项目,因此一个数据库就放在了D盘,路经是这样的:D:\eclipse\workspace\pro1\lib\db。 

找到了my.ini的配置文件中的: 

datadir="C:/Program Files/MySQL/MySQL Server 5.0/Data/" 

将其修改成:datadir="D:/eclipse/workspace /pro1/lib/db/" 

BUT我重启的时候,MySQL服务启动不了了。而且用MySQL-Front连接的时候提示: 主机127.0.0.1找不到。 

答:

使用符号链接吧,下面是mysql 5.0手册上的例子。 

Suppose that the MySQL data directory is C:\mysql\data and you want to have database foo located at D:\data\foo. Set u a symlink using this procedure 

Make sure that the D:\data\foo directory exists by creating it if necessary. If you already have a database directory named foo in the data directory, you should move it to D:\data. Otherwise, the symbolic link will be ineffective. To avoid problems, make sure that the server is not running when you move the database directory. 

Create a text file C:\mysql\data\foo.sym that contains the pathname D:\data\foo\. 

After this, all tables created in the database foo are created in D:\data\foo. Note that the symbolic link is not used if a directory with the same name as the database exists in the MySQL data directory. 

假设你的mysql安装在c:\mysql,数据目录就是c:\mysql\data,现在你想在D 盘建立一个名为foo的数据库,路径为d:\data\foo. 

首先:保证d:\data\foo目录存在,如果没有就创建或 者你c:\mysql\data下面有,就把它剪切过来,当然在停止mysql的情况下作移动,否则是不起任何作用的。 

再次: 在c:\mysql\data目录下建立一个文本文件命名为foo.sym,文件名与数据库名相同,后缀名为sym,里面的内容为:D:\data \foo\,就是foo数据库的绝对路径。