一、环境准备(关闭防火墙)
1、清除已安装数据库
[root@mysql01 ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.35-3.el7.x86_64
[root@mysql01 ~]# yum remove mariadb-libs-5.5.35-3.el7.x86_64
 
2、安装libaio-devel包
挂载光盘
配置yum仓库
[root@mysql01 yum.repos.d]# mount /dev/sr0 /mnt
[root@mysql01 yum.repos.d]# yum clean all
[root@mysql01 yum.repos.d]# yum repolist all
[root@mysql01 yum.repos.d]# yum intall -y libaio-devel
 
3、创建用户及用户密码
[root@mysql01 ~]# groupadd mysql
[root@mysql01 ~]# useradd -g mysql mysql
[root@mysql01 ~]# passwd mysql
Changing password for user mysql.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
 
4、创建数据目录、日志目录,并修改目录所有者所属组
[root@mysql01 ~]# mkdir -p /data/3306/data
[root@mysql01 ~]# mkdir -p /data/3306/binlog
[root@mysql01 yum.repos.d]# chown -R mysql.mysql /data*
 
二、上传MySQL数据库安装包并解压
[root@mysql01 stage]# ll
-rw-r--r--. 1 root root   664749587 Jun  9 20:46 mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
[root@mysql01 stage]# gunzip mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
[root@mysql01 stage]# ll
-rw-r--r--. 1 root root  2648074240 Jun  9 20:46 mysql-5.7.29-linux-glibc2.12-x86_64.tar
[root@mysql01 stage]# tar -xvf mysql-5.7.29-linux-glibc2.12-x86_64.tar
[root@mysql01 stage]# ll
drwxr-xr-x. 9 root root        4096 Jun  9 21:15 mysql-5.7.29-linux-glibc2.12-x86_64
-rw-r--r--. 1 root root  2648074240 Jun  9 20:46 mysql-5.7.29-linux-glibc2.12-x86_64.tar
 
三、创建软连接,并修改数据库安装目录所有者所属组
[root@mysql01 stage]# ln -s /stage/mysql-5.7.29-linux-glibc2.12-x86_64 /usr/local/mysql
[root@mysql01 stage]# ll /usr/local/
total 0
drwxr-xr-x. 2 root root  6 Mar 13  2014 bin
drwxr-xr-x. 2 root root  6 Mar 13  2014 etc
drwxr-xr-x. 2 root root  6 Mar 13  2014 games
drwxr-xr-x. 2 root root  6 Mar 13  2014 include
drwxr-xr-x. 2 root root  6 Mar 13  2014 lib
drwxr-xr-x. 2 root root  6 Mar 13  2014 lib64
drwxr-xr-x. 2 root root  6 Mar 13  2014 libexec
lrwxrwxrwx. 1 root root 42 Jun  9 21:17 mysql -> /stage/mysql-5.7.29-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root  6 Mar 13  2014 sbin
drwxr-xr-x. 5 root root 46 Mar 19  2019 share
drwxr-xr-x. 2 root root  6 Mar 13  2014 src
[root@mysql01 stage]# ll /usr/local/mysql/
total 292
drwxr-xr-x.  2 root root    4096 Jun  9 21:15 bin
drwxr-xr-x.  2 root root      52 Jun  9 21:15 docs
drwxr-xr-x.  3 root root    4096 Jun  9 21:15 include
drwxr-xr-x.  5 root root    4096 Jun  9 21:15 lib
-rw-r--r--.  1 7161 31415 276202 Dec 18 20:59 LICENSE
drwxr-xr-x.  4 root root      28 Jun  9 21:15 man
-rw-r--r--.  1 7161 31415    587 Dec 18 20:59 README
drwxr-xr-x. 28 root root    4096 Jun  9 21:15 share
drwxr-xr-x.  2 root root      86 Jun  9 21:15 support-files
 
四、修改环境变量并生效
[root@mysql01 stage]# vi /etc/profile
在文件末尾追加:
export PATH=/usr/local/mysql/bin:$PATH
[root@mysql01 stage]# source /etc/profile
[root@mysql01 stage]# mysql -V
mysql  Ver 14.14 Distrib 5.7.29, for linux-glibc2.12 (x86_64) using  EditLine wrapper
 
五、初始化
[root@mysql01 stage]# mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/3306/data
 
六、编辑my.cnf参数文件
[root@mysql01 stage]# vi /etc/my3306.cnf
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/data/3306/data
log_bin=/data/3306/binlog/mysql-bin
port=3306
server_id=1
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock
 
七、启动数据库
[root@mysql01 stage]# mysqld_safe --defaults-file=/etc/my3306.cnf &
 
八、登陆数据库
[root@mysql01 stage]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29-log MySQL Community Server (GPL)
 
Copyright (c) 2000, 2020, 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>
 
九、修改用户密码
alter user 'root'@'localhost' identified by 'newpassword';

最新文章

  1. swift-元组
  2. iOS-Runtime知识点整理
  3. require.js工作原理(初始)
  4. php封装微信SDK
  5. 杭电ACM1000
  6. 百度地图API多个点聚合时,标注添加的标签label地图刷新就丢失的问题解决
  7. Vector_h
  8. Python基础2- Hello,world
  9. Jenkins进阶系列之——02email-ext邮件通知模板
  10. ByteBuffer解析
  11. Spring_DI利用set方法赋值Demo
  12. STL之auto_ptr
  13. CentOS6.4中安装Python-Pip 以及Phyton gevent
  14. SQLServer 扫盲
  15. 远离DoS攻击 Windows Server 2016发布DNS政策
  16. 深入浅出数据结构C语言版(12)——平衡二叉查找树之AVL树
  17. Ajax跨域问题的出现和解决
  18. forEach循环对集合进行循环时,需判断是否为null;
  19. 第四次上机,ASP组件的使用
  20. loadrunner 脚本录制-录制选项设置HTML-based URL-based Script

热门文章

  1. SQL Server 数据库bak备份文件还原操作和mdf文件附加操作
  2. VScode,code::blocksC语言编译运行出现不支持的16位应用程序解决方法
  3. PHP的命令执行漏洞学习
  4. kali 系列学习07-攻击之密码生成
  5. 吉他指弹入门——贝斯(walking bass)
  6. 解决Jenkins可安装界面是空白的小技巧
  7. nginx学习首页随机模块
  8. Java蓝桥杯——递归练习题:走台阶(偶数版)
  9. C++里面this关键字的用法和功能
  10. 小bug小坑总结