目标:
安装mysql5.5.41,从Mysql 5.5.8开始,使用了新的cmake编译方式
mysql> select version();
+————+
| version() |
+————+
| 5.5.41-log |
+————+
1 row in set (0.00 sec)
环境: [root@www mysql-5.5.41]# cat /etc/redhat-release CentOS release 6.6 (Final) [root@www mysql-5.5.41]# uname -r 2.6.32-504.3.3.el6.x86_64 安装: #建立用户 [root@mysql /]# groupadd mysql [root@mysql /]# useradd -s /sbin/nologin -g mysql -M mysql #安装所需要系统库文件及需要的其他软件 [root@localhost ~]# yum install -y gcc gcc-c++ gcc-g77 autoconf [root@localhost ~]# yum install -y automake zlib* fiex* libxml* ncurses-devel [root@localhost ~]# yum install -y libtool-ltdl-devel* cmake bison #下载解压 mkdir -p /soft cd /soft wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.41.tar.gz tar -zxf mysql-5.5.41.tar.gz cd mysql-5.5.41 #配置,编译,安装 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.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_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DMYSQL_DATADIR=/usr/local/mysql/data make &&make install 以上参数等说明: DCMAKE_INSTALL_PREFIX=/usr/local/mysql # mysql安装的主目录,默认为/usr/local/mysql DMYSQL_DATADIR=/usr/local/mysql/data # mysql数据库文件的存放目录 DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock #系统Socket文件(.sock)设置 DSYSCONFDIR=/etc #mysql配置文件 my.cnf的存放地址,默认为/etc下 DMYSQL_TCP_PORT=3306 #数据库服务器监听端口,默认为3306 DENABLED_LOCAL_INFILE=1 # 允许从本地导入数据 DWITH_READLINE=1 # 快捷键功能 //下面3个是数据库编码设置 DEXTRA_CHARSETS=all # 安装所有扩展字符集,默认为all DDEFAULT_CHARSET=utf8 # 使用 utf8 字符 DDEFAULT_COLLATION=utf8_general_ci # 校验字符 提示:我们常用的字符集合校对规则; gbk | GBK Simplified Chinese | gbk_chinese_ci utf8 | UTF-8 Unicode | utf8_general_ci gb2312 | GB2312 Simplified Chinese | gb2312_chinese_ci //下面5个是数据库存储引擎设在 DWITH_MYISAM_STORAGE_ENGINE=1 # 安装 myisam 存储引擎(默认已经强制安装) DWITH_INNOBASE_STORAGE_ENGINE=1 # 安装 innodb 存储引擎(默认的存储引擎) DWITH_ARCHIVE_STORAGE_ENGINE=1 # 安装 archive 存储引擎 DWITH_BLACKHOLE_STORAGE_ENGINE=1 # 安装 blackhole 存储引擎 DWITH_PARTITION_STORAGE_ENGINE=1 # 安装数据库分区 提示: 1)当需要重新编译安装的时候,要先执行下面的2个命令,在cmake,否则会出错 To prevent old object files or configuration information from being used, run these commands on Unix before re-running CMake: shell> make clean shell> rm CMakeCache.txt 2)如果上面的过程中,有出现错误,请根据错误提示或者日志,检查原因 #创建配置文件,及授权 [root@mysql mysql-5.5.41]# chmod -R 755 /usr/local/mysql/ [root@mysql mysql-5.5.41]# chown -R mysql.mysql /usr/local/mysql/ [root@mysql mysql-5.5.41]# ls -li /usr/local/mysql/ … … [root@mysql mysql-5.5.41]#cp support-files/my-large.cnf /etc/my.cnf #mysql 初始化安装 /usr/local/mysql/scripts/mysql_install_db \ --basedir=/usr/local/mysql \ --datadir=/usr/local/mysql/data \ --user=mysql #启动&登录mysql [root@NFS-Server mysql-5.5.41]# cp support-files/mysql.server /etc/init.d/mysqld (启动脚本) [root@NFS-Server mysql-5.5.41]# chmod 700 /etc/init.d/mysqld [root@mysql mysql-5.5.41]# /etc/init.d/mysqld start #配置Mysql命令的全局使用路径 [root@NFS-Server mysql-5.5.41]# echo 'export PATH=$PATH:/usr/local/mysql/bin'>>/etc/profile [root@NFS-Server mysql-5.5.41]# source /etc/profile [root@NFS-Server mysql-5.5.41]# echo $PATH /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin [root@www bin]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.41-log Source distribution Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select version(); +------------+ | version() | +------------+ | 5.5.41-log | +------------+ 1 row in set (0.00 sec) #设置MySQL开机启动 [root@NFS mysql-5.5.41]# chkconfig --add mysqld [root@NFS mysql-5.5.41]# chkconfig mysqld on [root@NFS mysql-5.5.41]# chkconfig --list mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Linux下编译安装mysql5.5.41