yum –y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml2
ncurses-devel libmcrypt* libtool-ltdl-devel*
# mkdir -p /usr/local/mysql/
# groupadd mysql# useradd -g mysql mysql# chown mysql.mysql -R /usr/local/mysql/
mysql5.5以后是通过cmake来编译的
yum -y install cmake或者编译安装
#cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_TCP_PORT=3306 \
-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0
#make & make install
拷贝配置文件和启动文件
# cp support-files/my-medium.cnf /etc/my.cnf
# cp support-files/mysql.server /etc/init.d/mysqld
# chmod 755 /etc/init.d/mysqld
初始化数据库
# bash scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql
# /etc/init.d/mysqld start
# ln -s /usr/local/mysql/bin/* /sbin/或export PATH=/usr/local/mysql/bin:$PATH
续:
一台MySQL服务器启动多个端口(mysqld_multi)
# bash scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql - datadir=/usr/local/mysql/data3307
# bash scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql -- datadir=/usr/local/mysql/data3308
# bash scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql -- datadir=/usr/local/mysql/data3309
现在/usr/local/mysql下会自动创建data3307,08,09三个目录
#chown -R mysql.mysql ../mysql/data3307
#chown -R mysql.mysql ../mysql/data3308
#chown -R mysql.mysql ../mysql/data3309
#cp /usr/local/mysql-5.5.28/support-files/mysqld_multi.server /etc/init.d/mysqld_multi.server
#vi /etc/init.d/mysqld_multi.server
#修改basedir和bindir为安装路径
#basedir=/usr/local/mysql
#bindir=/usr/local/mysql/bin
用mysqld_multi工具查看该配置文件的模板方法,命令为:mysqld_multi --example
#mysqld_multi --example >>/etc/mysqld_multi.cnf直接将模板输入到被指文件,然后进行修改
如下:
- [mysqld_multi]
- mysqld = /usr/local/mysql/bin/mysqld_safe
- mysqladmin = /usr/local/mysql/bin/mysqladmin
- user = multi_admin
- password = my_password
- [mysqld2]
- socket = /tmp/mysql3307.sock
- port = 3307
- pid-file = /usr/local/mysql/data3307/localhost3307.pid
- datadir = /usr/local/mysql/data3307
- #language = /usr/local/mysql/share/mysql/english
- user = mysql
- [mysqld3]
- socket = /tmp/mysql3308.sock
- port = 3308
- pid-file = /usr/local/mysql/data3308/localhost3308.pid
- datadir = /usr/local/mysql/data3308
- #language = /usr/local/mysql/share/mysql/swedish
- user = mysql
- [mysqld4]
- socket = /tmp/mysql3309.sock
- port = 3309
- pid-file = /usr/local/mysql/data3309/localhost3309.pid
- datadir = /usr/local/mysql/data3309
- #language = /usr/local/mysql/share/mysql/estonia
- user = mysql
将/usr/local/mysql/bin加到$PATH环境变量里
export PATH=/usr/local/mysql/bin:$PATH
#mysqld_multi --defaults-extra-file=/etc/mysqld_multi.cnf report
#mysqld_multi --defaults-extra-file=/etc/mysqld_multi.cnf start
阅读(2607) | 评论(0) | 转发(0) |