my.cnf改变datadir,2天仍然没有运气

时间:2010-12-01 13:35:41

标签: mysql macos configuration

您好我几个小时都在尝试这个,这个论坛是我最后的选择 谷歌搜索了数百页。

问题: 对不起,但我正在提供我尝试过的详细信息

我已经设置了mysql并且工作正常,我现在需要将数据存储更改为指向我的外部HD。

使用mac osx没有默认的my.cnf所以我复制了 来自/usr/local/mysql-5.1.53-osx10.6-x86/support-files的my-huge.cnf,现在如果它有任何赔率我也在本地也有一个'mysql'文件夹。

当我将my-huge.cnf放入/重命名时 我按照指示将其重命名为my.cnf,
如果我不添加看起来像这样的datadir字段,它就像平常一样工作 datadir= /Volumes/Elements/database,
我还使用
将我的旧数据复制到我的新位置 sudo cp -R -p /var/lib/mysql /Volumes/Elements/database

除非我添加字段datadir = /Volumes/Elements/database,否则一切正常 到my.cnf文件,如果我得到错误

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

my.cnf文件如下所示

Macintosh-100:support-files seanf$ cd /etc 
Macintosh-100:etc seanf$ sudo nano my.cnf 
Password: 
Macintosh-100:etc seanf$ nano my.cnf 
Macintosh-100:etc seanf$ my.cnf > /Desktop/blah.txt 
-bash: /Desktop/blah.txt: No such file or directory 
Macintosh-100:etc seanf$ my.cnf < /Desktop/blah.txt 
-bash: /Desktop/blah.txt: No such file or directory 
Macintosh-100:etc seanf$ nano my.cnf 

GNU nano 2.0.6文件:my.cnf

# Example MySQL config file for very large systems. 
# 
# This is for a large system with memory of 1G-2G where the system runs mainly 
# MySQL. 
# 
# You can copy this file to 
# /etc/my.cnf to set global options, 
# mysql-data-dir/my.cnf to set server-specific options (in this 
# installation this directory is /usr/local/mysql/data) or 
# ~/.my.cnf to set user-specific options. 
# 
# In this file, you can use all long options that a program supports. 
# If you want to know which options a program supports, run the program 
# with the "--help" option. 

# The following options will be passed to all MySQL clients 
[client] 
#password = your_password 
port = 3306 
socket = /tmp/mysql.sock 

# Here follows entries for some specific programs 

# The MySQL server 
[mysqld]l 
datadir = /Volumes/Elements/database 
port = 3306 
socket = /tmp/mysql.sock 
skip-locking 
key_buffer_size = 384M 

等......

我希望有人可以阐明这一点,我有一份到期的作业,并且花了两天的时间试图让我的外部工作

即使当mysql正在工作并且我输入mysqld时,如果这是一个问题,我会收到错误吗?

Macintosh-100:lib s$ mysqld 
101201 13:31:13 [Warning] '--skip-locking' is deprecated and will be removed in a future >release. Please use '--skip-external-locking' instead. 
101201 13:31:13 [Warning] Can't create test file /usr/local/mysql-5.1.53-osx10.6-x86/data>/Macintosh-100.lower-test 
101201 13:31:13 [Warning] Can't create test file /usr/local/mysql-5.1.53-osx10.6-x86/data>/Macintosh-100.lower-test 
mysqld: Can't change dir to '/usr/local/mysql-5.1.53-osx10.6-x86/data/' (Errcode: 13) 
101201 13:31:13 [ERROR] Aborting 

101201 13:31:13 [Note] mysqld: Shutdown complete 

Macintosh-100:lib s$ 

感谢您的时间,我希望专家能够回答这个问题

2 个答案:

答案 0 :(得分:0)

虽然我没有使用datadir属性,但我已将数据存储位置更改为外部HD,方法是将默认位置安装到外部HD,如下所示:

  • 备份您当前的数据目录
  • 删除数据目录中的所有内容
  • 将其安装到外部HD(mount /var/lib/mysql/data /dev/XXX

我在Ubuntu Server上完成了它。在更改InnoDB特定目录时,我注意到必须小心权限(在ubuntu的情况下为apparmord)。当mysql无法执行某些文件系统操作时,我发现它的错误消息非常具有误导性。有时学习它的error.log(在我的例子中是/var/log/mysql/error.log)真的很有帮助。

希望这有助于您尽快解决问题。

答案 1 :(得分:0)

使用:

rsync -Pa /var/lib/mysql /Volumes/Elements/database

而不是:

cp -R -p /var/lib/mysql /Volumes/Elements/database

&#34; rsync -a&#34;可以保留一些对mysql很重要的权限。

相关问题