安装软件依赖包
yum -y install gcc gcc-c++ ncurses ncurses-devel cmake
下载软件包
cd /usr/local/src
wget https://downloads.MysqL.com/archives/get/file/MysqL-5.7.13.tar.gz --no-check-certificate
下载 boost 库,MysqL 5.7.5 开始Boost库是必需的
cd /usr/local/
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz --no-check-certificate
tar zxvf boost_1_59_0.tar.gz
创建安装用户
useradd -M -s /sbin/nologin MysqL
创建安装目录
mkdir -p /usr/local/MysqL
创建数据目录
mkdir /MysqL3306
创建配置文件目录
mkdir -p/usr/local/MysqL/etc
创建数据库日志目录
mkdir -p /usr/local/MysqL/logs
编译安装
cd /usr/local/src
tar zxvf MysqL-5.7.13.tar.gz
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/MysqL \
-DMysqL_DATADIR=/MysqL3306/ \
-DMysqL_UNIX_ADDR=/usr/local/MysqL/MysqL.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost_1_59_0
make && make install
创建 配置文件目录
mkdir -p /usr/local/MysqL/etc
cp support-files/my-default.cnf etc/my.cnf
编辑配置文件
修改安装目录的权限
chown -R MysqL:MysqL /usr/local/MysqL/
拷贝配置文件的启动脚本
cp /app/MysqL/MysqL/support-files/MysqL.server /etc/init.d/MysqLd
将MysqL 命令加入到环境变量
export PATH=$PATH:/usr/local/MysqL/bin
source /etc/profile
初始化数据库设置
./MysqLd --initialize-insecure
启动数据库
/etc/init.d/MysqLd start
数据库报错
/etc/init.d/MysqLd start
Starting MysqL.The server quit without updating PID file (/[Failed]l/MysqL/MysqLd.pid).
查看错误日志
chown -R MysqL:MysqL /MysqL3306
给数据库设置密码
版本更新后,原来user里的password字段已经变更为authentication_string
MysqL> update MysqL.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
Query OK,1 row affected,1 warning (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 1
MysqL> flush privileges;
登录验证