ITPub博客

首页 > Linux操作系统 > Linux操作系统 > mysql 5.5.15 源码包在linux5.5_x86_64 安装

mysql 5.5.15 源码包在linux5.5_x86_64 安装

原创 Linux操作系统 作者:wangxiangtao 时间:2011-08-08 16:52:55 0 删除 编辑

首先在mysql 的官方网站下载安装所需要的源码包, 由于源码包的安装需要cmake 的支持,因此:

[root@mysqla ~]# uname -a

Linux mysqla.richinfo.cn 2.6.18-194.el5xen #1 SMP Tue Mar 16 22:01:26 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

[root@mysqla ~]# cd /soft/

[root@mysqla soft]# ll

total 28652

-rw-r--r-- 1 root root  5517977 Aug  7 12:01 cmake-2.8.5.tar.gz

-rw-r--r-- 1 root root 23774015 Aug  7 12:02 mysql-5.5.15.tar.gz

(1) cmake 的安装

[root@mysqla soft]# tar -xvf cmake-2.8.5.tar.gz

[root@mysqla cmake-2.8.5]# vim Readme.txt

从文档中获取以下安装步骤

$ ./bootstrap;

make;

make install

(2) mysql 的安装

A. 建立 mysql 用户 以及mysql

[root@mysqla cmake-2.8.5]# groupadd mysql

[root@mysqla cmake-2.8.5]# useradd -g mysql mysql

B. 创建mysql数据库的相关目录, 并且赋予权限

[root@mysqla cmake-2.8.5]# mkdir  /usr/local/mysql

[root@mysqla cmake-2.8.5]# mkdir /data/mysql -p

[root@mysqla cmake-2.8.5]# mkdir /etc/mysql

 

[root@mysqla cmake-2.8.5]# chown mysql.mysql /usr/local/mysql

[root@mysqla cmake-2.8.5]# chown mysql.mysql /etc/mysql

[root@mysqla cmake-2.8.5]# chown mysql.mysql /data/mysql –R

[root@mysqla etc]# chmod 755 /data/mysql -R

[root@mysqla etc]# chmod 755 /etc/mysql

[root@mysqla etc]# chmod 755 /usr/local/mysql

C.编译 并安装 mysql

Cmake 采用以下参数

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/mysql/data/  \

-DSYSCONFDIR=/etc/mysql/ \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_FEDERATED_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DMYSQL_UNIX_ADDR=/etc/mysql/mysqld.sock \

-DMYSQL_TCP_PORT=3306 \

-DENABLED_LOCAL_INFILE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DMYSQL_USER=mysql

相关参数的 查询可以参考帮助文档:

[root@mysqla mysql-5.5.15]# cmake . -LH

-- MySQL 5.5.15

-- Configuring done

-- Generating done

-- Build files have been written to: /soft/mysql-5.5.15

-- Cache values

也可以 查看官档:

http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html

 

  • -DSYSCONFDIR=dir_name

The default my.cnf option file directory.   // mysql my.cnf 存放路径

  • DMYSQL_UNIX_ADDR=file_name

The Unix socket file path on which the server listens for socket connections. This must be an absolute path name. The default is /tmp/mysql.sock.

This value can be set at server startup with the --socket option.  //socket 的存放路径, 其文件用于服务器的监听和套接链接

################################################################

Cmake 时会出现如下警告信息:

CMake Warning:

  Manually-specified variables were not used by the project:

 MYSQL_USER

去掉 -DMYSQL_USER=mysql 参数

[root@mysqla mysql-5.5.15]# rm  CMakeCache.txt

rm: remove regular file `CMakeCache.txt'? y

继续编译 通过 

#############################################################################

 

如果出现一下错误:

cmake .

-- MySQL 5.5.8

-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)

CMake Error at cmake/readline.cmake:82 (MESSAGE):

  Curses library not found.  Please install appropriate package,

 

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

Call Stack (most recent call first):

  cmake/readline.cmake:126 (FIND_CURSES)

  cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)

  CMakeLists.txt:256 (MYSQL_CHECK_READLINE)

 

 

-- Configuring incomplete, errors occurred!

 

 

安装:

# yum -y install ncurses-devel

##############################################################################

 

Make

Make install

 

复制配置文件 my.cnf

[root@mysqla mysql]# cp /soft/mysql-5.5.15/support-files/my-medium.cnf /etc/mysql/my.cnf

使用chown chmod  更改 文件的权限与属组

 

配置开机自启动:

 

[root@mysqla mysql]# cp /soft/mysql-5.5.15/support-files/mysql.server /etc/init.d/mysql

[root@mysqla mysql]# chmod +x /etc/init.d/mysql

[root@mysqla mysql]# chkconfig  --add mysql

[root@mysqla mysql]# chkconfig mysql on

[root@mysqla mysql]# chkconfig --list | grep mysql

mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off

 

[root@mysqla mysql]# /usr/local/mysql/scripts/mysql_install_db  --basedir=/usr/local/mysql --datadir=/data/mysql/ --user=mysql

Installing MySQL system tables...

110807 16:25:41 [ERROR] Unknown collation: 'utf8-general_ci'

110807 16:25:41 [ERROR] Aborting

 

110807 16:25:41 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

由于在编译时采用了 错误的 DDEFAULT_COLLATION=utf8-general_ci(utf8_general_ci) 设置, 因此在my.cnf 使用了 character_set_server = utf8 初始化DB

但是在登录时,也出现了一下错误:

[root@mysqla mysql]# /usr/local/mysql/bin/mysql -uroot -p

Enter password:

/usr/local/mysql/bin/mysql: Collation 'utf8-general_ci' is not a compiled collation and is not specified in the '/usr/local/mysql/share/charsets/Index.xml' file

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

[root@mysqla mysql]#  /usr/local/mysql/bin/mysqladmin -u root password '123456'

/usr/local/mysql/bin/mysqladmin: Collation 'utf8-general_ci' is not a compiled collation and is not specified in the '/usr/local/mysql/share/charsets/Index.xml' file

 

 

[root@mysqla mysql]# vim /usr/local/mysql/share/charsets/Index.xml

 

 

[root@mysqla mysql]#  /usr/local/mysql/bin/mysqladmin -u root password '123456'

/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed

error: 'Access denied for user 'root'@'localhost' (using password: NO)'

 

更改了/usr/local/mysql/share/charsets/Index.xml 的内容:

  Unicode

  UTF-8 Unicode

  utf-8

  "utf8_general_ci"     id="33">

   primary

   compiled

 

              id="83">

    binary

    compiled

 

更改为:

  Unicode

  UTF-8 Unicode

  utf-8

  "utf8-general_ci"     id="33">

   primary

   compiled

 

              id="83">

    binary

    compiled

 

查看官方文档:

 

  • -DDEFAULT_COLLATION=collation_name

The server collation. By default, MySQL uses latin1_swedish_ci. Use the SHOW COLLATION statement to determine which collations are available for each character set.

This value can be set at server startup with the --collation_server option.

个人理解: 每个字符集都有自己的默认 校验字符集,  对于每种字符集的数据库, mysql 均会采用指定的collation 方式, 排序就会用到此校验规则。

mysql> create table tt (name varchar(10)) character set utf8;

Query OK, 0 rows affected (0.02 sec)

 

mysql> insert into tt values('aa');

Query OK, 1 row affected (0.01 sec)

 

mysql> insert into tt values('AA');

Query OK, 1 row affected (0.00 sec)

 

mysql> insert into tt values('ab');

Query OK, 1 row affected (0.01 sec)

 

mysql> insert into tt values('AB');

Query OK, 1 row affected (0.01 sec)

 

mysql> insert into tt values('ac');

Query OK, 1 row affected (0.00 sec)

 

mysql> insert into tt values('AC');

Query OK, 1 row affected (0.01 sec)

 

mysql> select * from tt order by name collate utf8_bin;

+------+

| name |

+------+

| AA   |

| AB   |

| AC   |

| aa   |

| ab   |

| ac   |

+------+

6 rows in set (0.01 sec)

 

mysql> select * from tt order by name collate utf8_general_ci;

+------+

| name |

+------+

| aa   |

| AA   |

| ab   |

| AB   |

| ac   |

| AC   |

+------+

6 rows in set (0.00 sec)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8117479/viewspace-704420/,如需转载,请注明出处,否则将追究法律责任。

上一篇: rman 异机恢复
请登录后发表评论 登录
全部评论

注册时间:2010-08-18

  • 博文量
    26
  • 访问量
    95311