前提
version mysql-5.5
platform centos6.x
添加用户
useradd -M -s /sbin/nologin mysql
安装需要的包
yum -y install compat-libstdc++-33.x86_64 libaio.x86_64
安装
tar xzvf mysql-5.5.43-linux2.6-x86_64.tar.gz
mkdir -p /storage/server
mv -f mysql-5.5.43-linux2.6-x86_64 /storage/server/
ln -sf /storage/server/mysql-5.5.43-linux2.6-x86_64 /storage/server/mysql
chown -R mysql:mysql /storage/server/mysql/
# 新建mysql数据目录
mkdir -p /storage/data/mysql
chown -R mysql:mysql /storage/data/mysql
初始化
scripts/mysql_install_db --user=mysql --basedir=/storage/server/mysql --datadir=/storage/data/mysql
修改配置文件
vim /etc/my.cnf
[mysqld] port = 3306 socket = /tmp/mysql.sock basedir = /storage/server/mysql datadir = /storage/data/mysql
启动(推荐用mysqld_safe)
/storage/server/mysql/bin/mysqld_safe &
# mysqld_safe默认mysqld的路径为 /usr/local/mysql/bin/mysqld,没有下面步骤用mysqld_safe启动会报错
mkdir -p /usr/local/mysql/bin
ln -sf /storage/server/mysql/bin/mysqld /usr/local/mysql/bin/mysqld
安全设置(根据脚本提示对数据库做一些安全设置)
/storage/server/mysql/bin/mysql_secure_installation