MySQL之基础-1 MySQL安装介绍之5.1版本Gcc安装

来源:互联网 发布:vb.net 应用程序路径 编辑:程序博客网 时间:2024/06/05 05:58
一、服务器基本环境:
系统版本:
[root@localhost ~]# cat /etc/redhat-release
CentOS release 5.8 (Final)

系统位数:
[root@localhost ~]# uname -i
x86_64

防火墙:
[root@localhost ~]# service iptables stop
[root@localhost ~]# service ip6tables stop
[root@localhost ~]# chkconfig iptables off
[root@localhost ~]# chkconfig ip6tables off

SElinux:
[root@localhost ~]# sed -i 's/=enforcing/=disabled/g' /etc/selinux/config
[root@localhost ~]# setenforce 0

/** 此处需要重启生效 */
[root@localhost ~]# sestatus
SELinux status:                 disabled

IP ADDRESS:
[root@localhost ~]# ifconfig eth0
eth0  Link encap:Ethernet  HWaddr 08:00:27:5D:6D:B2  
          inet addr:192.168.128.200  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fe80::a00:27ff:fe5d:6db2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:58608 errors:0 dropped:0 overruns:0 frame:0
          TX packets:844 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:4553888 (4.3 MiB)  TX bytes:103068 (100.6 KiB)
          Base address:0xd010 Memory:f0000000-f0020000

二、MySQL规划:
MySQL源码包版本:mysql-5.1.66.tar.gz
MySQL的安装位置:/usr/local/mysql
MySQL的配置文件:/etc/my.cnf
MySQL的数据目录:/data/


1.安装基础库:
# yum -y install make apr* autoconf automake curl curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel  keyutils patch perl kernel-headers compat*  cpp glibc libgomp libstdc++-devel keyutils-libs-devel libsepol-devel libselinux-devel krb5-devel  libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel  gettext gettext-devel ncurses* libtool* libxml2 libxml2-devel patch policycoreutils libjpeg libjpeg-devel libidn libidn-devel libpng libpng-devel glibc glibc-devel libjpeg* libpng* glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel  e2fsprogs e2fsprogs-devel krb5 krb5-devel bison expect ntp elinks wget vim*
如果Yum源在本地,则需要安装如下基础库:
# yum -yt groupinstall "Development Tools" "Development Libraries"

2.安装MySQL数据库:
# groupadd -g 27 mysql
# useradd -u 27 -g mysql -M -s /sbin/nologin mysql
# cd /usr/local/src/
# wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.66.tar.gz
# tar zxvf mysql-5.1.66.tar.gz
# cd mysql-5.1.66

解决MySQL 添加插件时提示 ERROR 1289 (HY000): The ‘plugin’ feature is disabled; you need MySQL built with ‘HAVE_DLOPEN’ to have it working 问题:
在编译MySQL时先执行下面的命令
# export CFLAGS="-O2 -DHAVE_DLOPEN=1"
# export CXXFLAGS="-O2 -DHAVE_DLOPEN=1"

# ./configure  --prefix=/usr/local/mysql 
--localstatedir=/data/  
--sysconfdir=/usr/local/mysql/     
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
--with-tcp-port=3306                   
--with-charset=utf8 
--with-extra-charsets=all 
--with-mysqld-user=mysql        
--with-big-tables 
--with-readline 
--with-ssl 
--with-embedded-server 
--with-pthread 
--without-ndb-debug 
--with-plugins=partition,federated,ndbcluster,innobase,csv,blackhole,myisam,heap,archive,innodb_plugin
--with-client-ldflags=-all-static  
--with-mysqld-ldflags=-all-static 
--with-server-suffix=-community 
--without-debug 
--enable-local-infile 
--enable-assembler 
--enable-thread-safe-client 
--enable-profiling > /root/mysql_setuplogs_configure.log 2>&1

参数详解:
--prefix=/usr/local/mysql        #指定安装路径
--localstatedir=/usr/local/mysql/data   #数据库文件路径  
--sysconfdir=/usr/local/mysql/etc       #配置文件路径
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
#MySQL Socket路径
--with-tcp-port=3306                    #运行端口  
--with-charset=utf8 #指定字符集 
--with-extra-charsets=all #指定附加字符集
--with-mysqld-user=mysql        #指定MySQL守护进程进程的用户名
--with-big-tables #启用大表功能
--with-readline #从"行"上面读取。实际就是一个行编辑库,bash在用,mysql也在用。
--with-ssl #开启SSL加密功能
--with-embedded-server #编译成embedded MySQL library (libmysqld.a)
--with-pthread #强制使用pthread库程序编译 
--without-ndb-debug #关闭ndb-debug模式
--with-plugins=partition,federated,ndbcluster,innobase,csv,blackhole,myisam,heap,archive,innodb_plugin
#添加存储引擎插件。重点:partition,innobase,myisam,innodb_plugin
--with-client-ldflags=-all-static #以纯静态方式编译客户端  
--with-mysqld-ldflags=-all-static #以纯静态方式编译服务端,提高13%性能(与客户端一起)
--with-server-suffix=-community #服务端后缀添加-community字符串到版本信息
--without-debug #关闭debug调试模式
--enable-local-infile #开启本地导入。LOCAL DATA INFILE INTO TABLE_NAME命令(默认不支持)
--enable-assembler #使用一些字符函数的汇编版本。汇编提升效率
--enable-thread-safe-client #客户端线程安全
--enable-profiling #Build a version with query profiling code 开启profile功能。
打开profile功能show profiles

/bin/rm: cannot remove `libtoolT': No such file or directory
config.status: executing default commands

查看libtool是否已经安装:
(1)确认libtool是否已经安装,如果没有安装的话,则先安装libtool
# rpm -qa | grep libtool
# yum -y install libtool

(2)分别执行以下三条命令:
# autoreconf --force --install
# libtoolize --automake --force
# automake --force --add-missing

# make > /root/mysql_setuplogs_make.log 2>&1
# make install > /root/mysql_setuplogs_makeinstall.log 2>&1
# cp support-files/my-medium.cnf /etc/my.cnf
# mkdir /mysql
# chown -R mysql.mysql /usr/local/mysql
# chown -R mysql.mysql /mysql
# /usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/data --user=mysql --socket=/tmp/mysql.sock
# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
# ldconfig

修改/etc/my.cnf文件,指定user/basedir/datadir/log-error/pid-file选项:
# vim /etc/my.cnf
[mysqld]
user            = mysql
basedir         = /usr/local/mysql
datadir         = /data
log-error       = /data/mysql.error.log
pid-file        = /data/mysql.pid

# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf  --user=mysql & 
# netstat --anptl | grep 3306
# cp support-files/mysql.server /etc/init.d/mysqld
# chmod +x /etc/init.d/mysqld 
# chkconfig --add mysqld
# chkconfig --level 35 mysqld on
# ln -s /usr/local/mysql/bin/* /usr/local/bin/
0 0
原创粉丝点击