centOS or ubuntu下安装mysql5.5

依赖库
ubuntu
apt-get install gcc g++ cmake make libncurses5-dev bison zip chkconfig
centos
yum install gcc gcc-c++ ncurses-devel zip make cmake

清理环境
rm -rf /etc/my.cnf
userdel mysql
groupdel mysql

安装mysql
cmake -DCMAKE_INSTALL_PREFIX=/application/search/mysql/mysql-5.5.32 \
-DMYSQL_DATADIR=/data0/search/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1

# -j16表示16线程编译,跟服务器内核相同速度会很快
make -j16 && make install -j16
安装结束

# 拷贝配置文件(只有5.5有,5.6里没有)
cd /application/search/mysql/mysql-5.5.32/support-files
mkdir ../etc
cp my-innodb-heavy-4G.cnf ../etc/my.cnf


修改 /application/search/mysql/mysql-5.5.32/etc/my.cnf
===============================================================
#修改所有 socket          = /application/search/mysql/mysql-5.5.32/tmp/mysql.sock
[mysqld]
#添加
datadir         = /data0/search/mysql/data


[mysql]
default-character-set=utf8

[mysqld]
character-set-server=utf8
default-storage-engine=INNODB #修改
skip-host-cache
skip-name-resolve
===============================================================

【可选,本人一般不做此操作】添加mysql运行的用户和用户组
cd /usr/local/mysql
groupadd mysql
useradd -g mysql mysql
chown -R root .
chown -R mysql data
chgrp -R mysql .

手工创建目录,不创建会报错(配置my.cnf的时候能用上)
mkdir -p /data0/search/mysql/data
mkdir -p /data0/search/mysql/log
mkdir -p /application/search/mysql/mysql-5.5.32/tmp

初始化mysql数据文件及日志文件
cd /application/search/mysql/mysql-5.5.32/scripts
./mysql_install_db --basedir=/application/search/mysql/mysql-5.5.32 --datadir=/data0/search/mysql/data --user=search --defaults-file=/application/search/mysql/mysql-5.5.32/etc/my.cnf

# 拷贝启动shell脚本,这个脚本对启动进行了优化,不使用也没问题
cd /application/search/mysql/mysql-5.5.32/support-files
cp mysql.server ../mysqld

起停一(指定配置文件,--defaults-file=/usr/local/mysql/my.cnf)
./bin/mysqld &
./bin/mysqladmin shutdown -uroot

起停二
sh mysqld start
sh mysqld stop


附录
安装 cmake http://phl.iteye.com/blog/1974496

你可能感兴趣的:(数据结构,mysql,工作)