mysql 5.5.15 安装笔记

mysql-5.5.15 安装笔记

mysql 最新的版本都需要cmake编译安装,估计以后的版本也会采用这种方式,所以特地记录一下安装步骤及过程,以供参考。

注意:此安装是默认centos下已经安装了最新工具包,比如GNU make, GCC, Perl, libncurses5-dev,如果在编译安装过程中发现有缺失的工具包,先yum install 单独下载安装再继续即可。


下面这个脚本,就是为安装做准备的,删除centos默认安装的httpd等rpm包,并下载gcc等    devel.sh

#!/bin/sh
rpm -qa|grep  httpd
rpm -e httpd
rpm -qa|grep mysql
rpm -e mysql
rpm -qa|grep php
rpm -e php

yum -y remove httpd
yum -y remove httpd*
yum -y remove mysql*
yum -y remove php*

yum -y install yum-fastestmirror
yum -y remove httpd
yum -y update

#Synchronization time
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

yum install -y ntp
ntpdate -d cn.pool.ntp.org
date

yum -y install patch make gcc gcc-c++ gcc-g77 flex bison file
yum -y install libtool libtool-libs autoconf kernel-devel
yum -y install libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel
yum -y install freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
yum -y install glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel
yum -y install ncurses ncurses-devel curl curl-devel e2fsprogs
yum -y install e2fsprogs-devel krb5 krb5-devel libidn libidn-devel
yum -y install openssl openssl-devel vim-minimal nano sendmail
yum -y install fonts-chinese gettext gettext-devel
yum -y install ncurses-devel
yum -y install gmp-devel pspell-devel
yum -y install unzip

 

一. Centos 用 wget 下载需要的软件,保存到目录 /usr/local/src/ 下

wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.15.tar.gz/from/http://mysql.he.net/

wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
 

二. 安装 cmake

cd /root/soft

tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./bootstrap
make
make install
cd ../

 

三. 编译安装 MySQL 5.5.15


/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql

tar xvf mysql-5.5.15.tar.gz
cd mysql-5.5.15/

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/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_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysql/data \
-DMYSQL_USER=mysql

make
make install

chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql

ln -s /usr/local/mysql/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16


mkdir -p /var/mysql/
mkdir -p /var/mysql/data/
mkdir -p /var/mysql/log/
chown -R mysql:mysql /var/mysql/

cd support-files/

cp my-large.cnf /var/mysql/my.cnf

cp mysql.server /etc/init.d/mysqld


四. 配置启动MySQL 5.5.15

1. 若有需要请先修改 mysql 的配置 my.cnf

vi /var/mysql/my.cnf


2. mysql 初始化安装

/usr/local/mysql/scripts/mysql_install_db \
--defaults-file=/var/mysql/my.cnf \
--basedir=/usr/local/mysql \
--datadir=/var/mysql/data \
--user=mysql


3. 将 mysql 加入开机启动

chmod +x /etc/init.d/mysqld
vi /etc/init.d/mysqld (编辑此文件,查找并修改以下变量内容:)
basedir=/usr/local/mysql
datadir=/var/mysql/data

chkconfig --add mysqld
chkconfig --level 345 mysqld on

4. 启动 mysql

service mysqld start


5. 安全配置

设置密码
#/usr/local/mysql/bin/mysqladmin -u root password 'newpassword'

设置远程访问密码,下一命令会关闭root远程访问。此命令可能失败, telnet root 3306  ,不通,正常,继续
#/usr/local/mysql/bin/mysqladmin -u root -h root password 'newpassword'


安全配置

#/usr/local/mysql/bin/mysql_secure_installation

6.重启服务,搞定
#/etc/init.d/mysqld restart

7.如果需要另外新加账户,进入mysql,授权即可

mysql> grant all privileges  on testdb.* to my_user@'%' identified by '123345';

 

 

 

 

 


 

你可能感兴趣的:(mysql 5.5.15 安装笔记)