Loading

Centos7编译安装mysql5.7

1.下载mysql安装包

https://www.mysql.com/downloads/

2. 安装mysql依赖的包文件

yum install -y libaio numactl-libs

3.创建mysql的用户组

mysql不需要登陆系统,所以不需要bin的权限。

# useradd -r -s /bin/false mysql

4. 解压程序并创建链接文件

# tar -xvf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz  -C /usr/local/
# cd /usr/local
# ln -s mysql-5.7.29-linux-glibc2.12-x86_64/ mysql
# ln -s root.root /usr/local/mysql

5. 准备环境变量

# echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
# . /etc/profile.d/mysql.sh 

6.准备配置文件

# cp /etc/my.cnf{,.bak}
datadir=/data/mysql
socket=/data/mysql/mysql.sock
log-error=/data/mysql/mysql.log
pid-file=/data/mysql/mysql.pid

[client]
socket=/data/mysql/mysql.sock

7. 生成数据库文件提取数据库密码

# mkdir /data/mysql -p
# mysqld --initialize --user=mysql --datadir=/data/mysql
# grep password /data/mysql/mysql.log 
2021-02-18T13:19:45.993964Z 1 [Note] A temporary password is generated for root@localhost: d4,+b1pXhav,

8. 准备mysql启动脚本

# cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld
# ls /usr/local/mysql/support-files/
magic  mysqld_multi.server  mysql-log-rotate  mysql.server

# chkconfig --add mysqld
# chkconfig --list

9. 启动mysql

# service mysqld start
Starting MySQL. SUCCESS!
posted @ 2021-02-19 20:10  梨花海棠  阅读(142)  评论(0编辑  收藏  举报