【问题标题】:my.cnf changing datadir, 2days and still no luckmy.cnf 更改 datadir,2 天,仍然没有运气
【发布时间】:2010-12-01 13:35:40
【问题描述】:

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

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

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

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

当我将 my-huge.cnf 放置并重命名为 /etc
我按照指示将其重命名为 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 

等等……

我希望有人能阐明这一点,我有一个任务到期,并且花了 2 天时间试图让这个在我的外部工作

即使 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$ 

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

【问题讨论】:

  • 你的新数据目录应该由 MySQL 拥有和写入
  • 我理解错误> ERROR 2002 (HY000): Can't connect to local MySQL server through socket 取决于mysql服务器没有运行,the solution can be found here

标签: mysql macos configuration


【解决方案1】:

虽然我没有玩过datadir 属性,但我已通过将默认位置安装到外部硬盘,将数据存储位置更改为外部硬盘,如下所示:

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

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

希望这可以帮助您尽快解决问题。

【讨论】:

  • 问题出在最后一些奇怪的权限设置
【解决方案2】:

用途:

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

代替:

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

“rsync -a”可以保留一些对mysql很重要的权限。

【讨论】:

    猜你喜欢
    • 2011-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多