在centos7.7系统中二进制简单安装MySQL5.7.27

1. 删除CentOS7.7默认数据库配置文件

  • 查看默认数据库配置文件
[root@CentOS7 ~]# find -H /etc/ | grep my.c  #查看默认数据库配置文件
/etc/pki/tls/certs/make-dummy-cert
/etc/pki/tls/certs/renew-dummy-cert
/etc/my.cnf
/etc/my.cnf.d
/etc/my.cnf.d/mysql-clients.cnf
  • 删除默认数据库配置文件
[root@CentOS7 ~]# rm -rf /etc/my.cnf /etc/my.cnf.d/  删除默认数据库配置文件
  • 再次查看默认数据库配置文件
[root@Centos7 ~]# find -H /etc/ | grep my.c #再次查看默认数据库配置文件 
/etc/pki/tls/certs/make-dummy-cert
/etc/pki/tls/certs/renew-dummy-cert

到目前为止, 系统最小化安装自带的数据库配置文件已经删除干净了!

2.卸载系统自带mariadb-libs

  • 查询
[root@CentOS7 ~]# rpm -qa|grep mariadb-libs
mariadb-libs-5.5.64-1.el7.x86_64
  • 卸载
[root@CentOS7 ~]# rpm -e mariadb-libs-5.5.64-1.el7.x86_64 --nodeps
warning: file /etc/my.cnf.d/mysql-clients.cnf: remove failed: No such file or directory
warning: file /etc/my.cnf.d: remove failed: No such file or directory
warning: file /etc/my.cnf: remove failed: No such file or directory
[root@CentOS7 ~]# rpm -qa|grep mariadb-libs

安装相关包

[root@CentOS7 ~]# yum  -y install libaio numactl-libs

用户和组

[root@CentOS7 ~]# groupadd mysql
[root@CentOS7 ~]# useradd -r -g mysql -s /bin/false mysql

准备程序文件

[root@CentOS7 ~]# tar xf mysql--5.7.27-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@CentOS7 ~]# cd /usr/local/
[root@CentOS7 local]# ln -s mysql-5.7.27-linux-glibc2.12-x86_64/ mysql
[root@CentOS7 local]# ll
total 0
drwxr-xr-x. 2 root root   6 Apr 11  2018 bin
drwxr-xr-x. 2 root root   6 Apr 11  2018 etc
drwxr-xr-x. 2 root root   6 Apr 11  2018 games
drwxr-xr-x. 2 root root   6 Apr 11  2018 include
drwxr-xr-x. 2 root root   6 Apr 11  2018 lib
drwxr-xr-x. 2 root root   6 Apr 11  2018 lib64
drwxr-xr-x. 2 root root   6 Apr 11  2018 libexec
lrwxrwxrwx. 1 root root  36 Feb 22 20:15 mysql -> mysql-5.7.27-linux-glibc2.12-x86_64/
drwxr-xr-x. 9 root root 129 Feb 22 20:14 mysql-5.7.27-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root   6 Apr 11  2018 sbin
drwxr-xr-x. 5 root root  49 Feb  8 18:00 share
drwxr-xr-x. 2 root root   6 Apr 11  2018 src
[root@CentOS7 local]# chown -R root.root /usr/local/mysql/

准备环境变量

[root@CentOS7 local]# echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh 
[root@CentOS7 local]# . /etc/profile.d/mysql.sh

准备配置文件

[root@CentOS7 local]# vim /etc/my.cnf

[mysqld] 
datadir=/data/mysql 
skip_name_resolve=1 
socket=/data/mysql/mysql.sock         
log-error=/data/mysql/mysql.log 
pid-file=/data/mysql/mysql.pid 

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

生成数据库文件,并提取root密码

[root@CentOS7 local]# ./mysql-5.7.27-linux-glibc2.12-x86_64/bin/mysqld \
--initialize \
--user=mysql \
--datadir=/data/mysql
[root@CentOS7 local]# grep password /data/mysql/mysql.log
2020-02-22T12:24:33.532230Z 1 [Note] A temporary password is generated for root@localhost: Ioq-#Iyk2Uh8

[root@CentOS7 local]# awk '/temporary password/{print $NF}' /data/mysql/mysql.log 
Ioq-#Iyk2Uh8   #这个是密码

准备服务脚本和启动

[root@CentOS7 local]# cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld 
[root@CentOS7 local]# chkconfig --add mysqld
[root@CentOS7 local]# service mysqld start
Starting MySQL. SUCCESS! 
[root@CentOS7 local]# mysql -uroot -pIoq-#Iyk2Uh8
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.27

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值