mysql的安装
1.安装依赖包
yum -y install wget gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex*
libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake bison
bison-devel ncurses-devel perl
2.新建用户组
groupadd mysql
useradd mysql -g mysql
3.上传并解压安装包
cd /home/home/app/tools
tar -zxv -f mysql-5.6.19.tar.gz
cd mysql-5.6.19
4.cmake编译参数安装
cmake \
-DCMAKE_INSTALL_PREFIX=/home/app/mysql-5.6.19 \
-DMYSQL_UNIX_ADDR=/home/app/mysql-5.6.19/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/home/app/mysql-5.6.19/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
make && make install
ln -s /home/app/mysql-5.6.19 /home/mysql
5. 复制配置文件
sudo cp /home/app/mysql-5.6.19/support-files/my-default.cnf /etc/my.cnf
6.添加系统变量
echo 'export PATH=/home/app/mysql-5.6.19/bin:$PATH' >>/etc/profile
echo "export PATH" >> /etc/profile
source /etc/profile
echo $PATH
7.进入安装路径并授权mysql用户:
cd /home/app/mysql-5.6.19
mkdir -p /home/app/mysql-5.6.19/data
chown -R mysql.mysql /home/app/mysql-5.6.19/
8.调整/tmp授权,否则初始化会错误:
chmod -R 1777 /tmp
9. 执行初始化:
cd /home/app/mysql-5.6.19/scripts/
./mysql_install_db --basedir=/home/app/mysql-5.6.19/ --datadir=/home/app/mysql-5.6.19/data/ --user=mysql
10.把服务启动脚本添加到/etc/init.d目录下:
sudo cp /home/app/mysql-5.6.19/support-files/mysql.server /etc/init.d/mysqld
11.启动MySQL服务,设置密码,设置开机启动。
/etc/init.d/mysqld start
netstat -lntup|grep mysql
/home/app/mysql-5.6.19/bin/mysqladmin -u root password 'root'
chkconfig mysqld on
echo "ok!"