现在的位置: 首页 > IT运维 > 正文

MAC编译安装MYSQL 5.5

2011年10月30日 IT运维 ⁄ 共 1977字 暂无评论 ⁄ 被围观 45+

cmake

下载cmake, 官网下载地址:

http://www.cmake.org/cmake/resources/software.html

目前最新版本2.8.6,直接下载mac版本即可,我下载的是: http://www.cmake.org/files/v2.8/cmake-2.8.6-Darwin64-universal.dmg

mysql用户

因为mac内置mysql, 用户也已经默认添加,所以无需添加mysql用户。

下载mysql 5.5源码

官网下载地址: http://dev.mysql.com/downloads/mysql/, 选择 Generic Linux (Architecture Independent), Compressed TAR Archive(mysql-5.5.17.tar.gz)下载即可

编译安装

cmake . -DCMAKE_INSTALL_PREFIX=/Users/yourname/webs/mysql
make && sudo make install

make过程中会出现如下错误:

/var/folders/d4/3dnh59tx7wd6y2wzl_x8_r700000gn/T//ccyRpMBr.s:596:suffix or operands invalid for `add'
make[2]: *** [unittest/mysys/CMakeFiles/my_atomic-t.dir/my_atomic-t.c.o] Error 1

这是1个mysql test代码中的bug,修复方法为:打开unittest/mysys/my_atomic-t.c, 找到do_test()函数体,注释其中的int64数据测试部分,并强制返回测试成功标志,修改后的代码如下:

void do_tests()
{
  plan(6);

  bad= my_atomic_initialize();
  ok(!bad, "my_atomic_initialize() returned %d", bad);

  my_atomic_rwlock_init(&rwl);

  b32= c32= 0;
  test_concurrently("my_atomic_add32", test_atomic_add, THREADS, CYCLES);
  b32= c32= 0;
  test_concurrently("my_atomic_fas32", test_atomic_fas, THREADS, CYCLES);
  b32= c32= 0;
  test_concurrently("my_atomic_cas32", test_atomic_cas, THREADS, CYCLES);

  {
    int64 b=0x1000200030004000LL;
    a64=0;
    /*my_atomic_add64(&a64, b);
    ok(a64==b, "add64");  注释这段代码*/
    ok(1, "add64"); /* 添加这句代码,目的是直接返回测试成功结果 */ 
  }
  a64=0;
  test_concurrently("my_atomic_add64", test_atomic_add64, THREADS, CYCLES);

  my_atomic_rwlock_destroy(&rwl);
}

修复完成后,不需要重新configure,重复make && sudo make install你可

产生这个bug的原因是不允许64位立即值,有一段英文解释,我觉得原文意思表达的比较准确,直接上原文吧:

In unittest/mysys/my_atomic-t.c, the call to "my_atomic_add64" with a 64 bit value as an argument is what's causing the bad assembly. In fact, in the failing GAS instruction: 

addq $1152956689784258560, (%rbx) 

a 64bit immediate value is NOT ALLOWED. Note that 1152956689784258560 is the 
same as 0x1000200030004000 which is the value used in the test below. Thus the inline code generation for my_atomic_add64() won't work for 64 bit values.

初始化及配置

MySQL5.5安装后不需要初始化基本库,只需复制配置文件到/etc即可

sudo cp support-files/my-small.cnf /etc/my.cnf

后续的修改数据库账号、安全加固、应用,balabala....

给我留言

您必须 [ 登录 ] 才能发表留言!

×
#