日期:2014-05-16  浏览次数:20687 次

linux下mysql的安装
mysql5.5安装例子一
——————————————————————
在linux下mysql 5.5安装   2011-08-10 

1、安装所需要系统库相关库文件


2、创建mysql安装目录
  # mkdir -p /usr/local/mysql/

3、创建数据存放目录
  # mkdir -p /service/mysql/
4、创建用户和用户组与赋予数据存放目录权限
  # groupadd mysql
  # useradd -g mysql mysql
  # chown mysql.mysql -R /service/mysql/
5、安装cmake(mysql5.5以后是通过cmake来编译的)
  # wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
  # tar zxvf cmake-2.8.4.tar.gz
  # cd cmake-2.8.4
  #./configure
  # make && make install

6、下载解压mysql 5.5.15
  wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.15.tar.gz
  [root@localhost down]# tar zxvf mysql-5.5.15.tar.gz
  [root@localhost down]# cd mysql-5.5.15


7、编辑mysql


cmake . \

> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql\
> -DMYSQL_DATADIR=/service/data/\
> -DMYSQL_UNIX_ADDR=/service/data/mysqld.sock\
> -DWITH_INNOBASE_STORAGE_ENGINE=1\
> -DSYSCONFDIR=/etc\
> -DEXTRA_CHARSETS=all\
> -DDEFAULT_CHARSET=utf8\
> -DDEFAULT_COLLATION=utf8-general_ci\
> -DMYSQL_USER=mysql\

> -DWITH_DEBUG=0




-DMYSQL_UNIX_ADDR=/service/data/mysqld.sock\
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/service/data/\
-DMYSQL_USER=mysql



cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/service/data/ -DMYSQL_UNIX_ADDR=/service/data/mysqld.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci  -DWITH_DEBUG=0





源代码配置选项说明:

                     //mysql安装的主目录,5.5.8版本默认为/usr/local/mysql,所以可以不添加

                     -DCMAKE_INSTALL_PREFIX=/usr/local/mysql



                     //mysql数据保存的路径,自定义

                     -DMYSQL_DATADIR=/home/system_username/mysql/mysqldata  



                     //mysql配置文件地址------The default my.cnf option file directory

                     -DSYSCONFDIR=/etc



                     //Compile storage engine xxx statically into server

                     /*Storage engines are built as plugins. You can build a plugin as a static module (compiled into the server)    

                      *or a dynamic module  (built as a dynamic library that must be installed into the server using the INSTALL  

            &n