MySQL二进预编译制安装

时间:2021-05-29 14:28:35

+++++++++++++++++++++++++++++++++++++++++++
标题:MySQL二进预编译制安装
时间:2019年2月25日
内容:MySQL二进制预编译安装
重点:MySQL二进制预编译安装
+++++++++++++++++++++++++++++++++++++++++++

友情提示:如果安装过程中遇到问题,可以留言到我的博客园,发现后立即回复
安装流程指导:http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
部分依赖软件:https://dev.mysql.com/downloads/mysql/5.7.html#downloads

1. MySQL的RPM软件包校验
# md5sum mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz

2. 使用自定义配置文件(该配置文件仅限用于本实验,线上数据库需根据业务需求自定义配置文件)
# vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/files/mysql.sock
user=mysql
symbolic-links=0
[mysqld_safe]
log-error=/usr/local/mysql/files/mysqld.log
pid-file=/usr/local/mysql/files/mysqld.pid

3. 安装MySQL数据库
# tar zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
# mv /soft/mysql-5.7.25-linux-glibc2.12-x86_64 /usr/local/mysql
# useradd -s /sbin/nologin mysql
# mkdir /usr/local/mysql/data //存放mysql的数据文件
# mkdir /usr/local/mysql/files //sock文件、pid文件、日志文件
# touch /usr/local/mysql/files/mysqld.log //需要先创见日志文件
# chown -R mysql:mysql /usr/local/mysql/
# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data //初始化数据库
# /usr/local/mysql/bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data/
# chown -R mysql:mysql /usr/local/mysql/
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
# vim /etc/profile //环境变量
  export MYSQL_HOME=/usr/local/mysql
  export PATH=$PATH:$MYSQL_HOME/bin
# source /etc/profile
# mysql
mysql> alter user root@"localhost" identified by "new_password";