Centos 7下安装MySQL 5.5
以管理员身份进行以下操作:
删除centos预先安装的mariadb
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
rpm -qa | grep mariadb
安装MySQL依赖
yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*
创建MySQL工作目录
cd ~ && mkdir mysql && cd mysql
安装cmake
wget http://www.cmake.org/files/v3.4/cmake-3.4.0.tar.gz
tar -zxvf cmake-3.4.0.tar.gz && cd cmake-3.4.0
./configure
gmake && make install
安装MySQL
rm -rf /etc/my.cnf && rm -rf /etc/init.d/mysqld
userdel mysql
groupdel mysql
groupadd mysql
useradd -g mysql mysql
cd ~/mysql
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.54.tar.gz
tar -zxvf mysql-5.5.54.tar.gz cd mysql-5.5.54
执行cmake命令
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_ENGIME=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_USER=mysql
make && make install
修改MySQL文件权限,创建软连接,复制MySQL配置文件等
chmod +w /usr/local/mysql && chown -R mysql:mysql /usr/local/mysql
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18 #软连接
cd support-files #里面有多个my-*.cnf,large,huge,small,medium,不同的配置适用于不同的机器
cp my-large.cnf /etc/my.cnf && cp mysql.server /etc/init.d/mysqld
修改配置文件