centos7安装mysql(mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar)

Linux安装mysql(mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar)

1.下载mysql

官网地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads

2.下载完成后,通过ftp上传到Linux服务器上

(1)创建mysql5.7.23目录


 
 
  1. [root@VM_0_16_centos ~]# mkdir mysql5 .7 .23
  2. mysql5 .7 .23

(2)将下载好的安装上传到该目录下


 
 
  1. [root@VM_0_16_centos ~]# cd mysql5 .7 .23
  2. [root@VM_0_16_centos mysql5.7.23]# ls
  3. mysql-5 .7 .23-1 .el7 .x86_64 .rpm-bundle .tar


3.解压安装包(mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar)


 
 
  1. [root@VM_0_16_centos mysql5.7.23]# tar xvf mysql-5 .7 .23-1 .el7 .x86_64 .rpm-bundle .tar
  2. mysql-community-common-5 .7 .23-1 .el7 .x86_64 .rpm
  3. mysql-community-libs-compat-5 .7 .23-1 .el7 .x86_64 .rpm
  4. mysql-community-minimal-debuginfo-5 .7 .23-1 .el7 .x86_64 .rpm
  5. mysql-community-server-5 .7 .23-1 .el7 .x86_64 .rpm
  6. mysql-community-devel-5 .7 .23-1 .el7 .x86_64 .rpm
  7. mysql-community-libs-5 .7 .23-1 .el7 .x86_64 .rpm
  8. mysql-community-client-5 .7 .23-1 .el7 .x86_64 .rpm
  9. mysql-community-server-minimal-5 .7 .23-1 .el7 .x86_64 .rpm
  10. mysql-community-test-5 .7 .23-1 .el7 .x86_64 .rpm
  11. mysql-community-embedded-devel-5 .7 .23-1 .el7 .x86_64 .rpm
  12. mysql-community-embedded-5 .7 .23-1 .el7 .x86_64 .rpm
  13. mysql-community-embedded-compat-5 .7 .23-1 .el7 .x86_64 .rpm
  14. [root@VM_0_16_centos mysql5.7.23]#

 4.卸载掉centos7自带的mariadb-lib

方法一:

(1)查询mariadb信息


 
 
  1. [root@VM_0_16_centos mysql5. 7.23] # rpm -qa|grep mariadb
  2. mariadb-libs- 5.5. 56- 2.el7.x86_64

(2)使用rpe -e命令卸载

[root@VM_0_16_centos mysql5.7.23]# rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps
 
 

此方法卸载失败或者报错,请使用方法二

方法二:

使用yum remove 命名进行删除


 
 
  1. [root@VM_0_16_centos mysql5. 7.23] # yum remove mysql-libs
  2. ------------------------------------------------------------------------------------------------------------------------
  3. 已加载插件:fastestmirror, langpacks
  4. 正在解决依赖关系
  5. --> 正在检查事务
  6. ---> 软件包 mariadb-libs.x86_64. 1.5. 5.44- 2.el7.centos 将被 删除
  7. --> 正在处理依赖关系 libmysqlclient.so. 18()( 64bit),它被软件包 2:postfix- 2.10. 1- 6.el7.x86_64 需要
  8. --> 正在处理依赖关系 libmysqlclient.so. 18(libmysqlclient_18)( 64bit),它被软件包 2:postfix- 2.10. 1- 6.el7.x86_64 需要
  9. --> 正在检查事务
  10. ---> 软件包 postfix.x86_64. 2.2. 10.1- 6.el7 将被 删除
  11. --> 解决依赖关系完成
  12. base/ 7/x86_64 | 3.6 kB 00: 00: 00
  13. extras/ 7/x86_64 | 3.4 kB 00: 00: 00
  14. updates/ 7/x86_64 | 3.4 kB 00: 00: 00
  15. 依赖关系解决
  16. =======================================================================================================================================
  17. Package 架构 版本 源 大小
  18. =======================================================================================================================================
  19. 正在删除:
  20. mariadb-libs x86_64 1: 5.5. 44- 2.el7.centos @anaconda 4.4 M
  21. 为依赖而移除:
  22. postfix x86_64 2: 2.10. 1- 6.el7 @anaconda 12 M
  23. 事务概要
  24. =======================================================================================================================================
  25. 移除 1 软件包 (+ 1 依赖软件包)
  26. 安装大小: 17 M
  27. 是否继续?[ y/N]:y
  28. Downloading packages:
  29. Running transaction check
  30. Running transaction test
  31. Transaction test succeeded
  32. Running transaction
  33. 警告:RPM 数据库已被非 yum 程序修改。
  34. ** 发现 4 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
  35. icedtea-web-1.6.1-4.el7.x86_64 有缺少的需求 java-1.8.0-openjdk
  36. jline-1.0-8.el7.noarch 有缺少的需求 java >= ('0', '1.5', None)
  37. 1:libreoffice-core-4.3.7.2-5.el7.x86_64 有缺少的需求 java-headless >= ('1', '1.6', None)
  38. 1:libreoffice-ure-4.3.7.2-5.el7.x86_64 有缺少的需求 libjvm.so()(64bit)
  39. 正在删除 : 2:postfix-2.10.1-6.el7.x86_64 1/2
  40. 正在删除 : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 2/ 2
  41. 验证中 : 1:mariadb-libs- 5.5. 44- 2.el7.centos.x86_64 1/ 2
  42. 验证中 : 2:postfix- 2.10. 1- 6.el7.x86_64 2/ 2
  43. 删除:
  44. mariadb-libs.x86_64 1: 5.5. 44- 2.el7.centos
  45. 作为依赖被删除:
  46. postfix.x86_64 2: 2.10. 1- 6.el7
  47. 完毕!

5.安装mysql-server服务,只需要安装如下4个软件包即可,使用rpm -ivh进行安装(按顺序安装,后面的服务依赖前面的服务)


 
 
  1. [root@VM_0_16_centos mysql5. 7.23] # rpm -ivh mysql-community-common-5.7.23-1.el7.x86_64.rpm
  2. 警告:mysql-community-common- 5.7. 23- 1.el7.x86_64. rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072 e1f5: NOKEY
  3. 准备中... ################################# [100%]
  4. 正在升级/安装...
  5. 1 :mysql-community-common- 5.7. 23- 1.e ################################# [100%]
  6. [root@VM_0_16_centos mysql5. 7.23] # rpm -ivh mysql-community-libs-5.7.23-1.el7.x86_64.rpm
  7. 警告:mysql-community-libs- 5.7. 23- 1.el7.x86_64. rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072 e1f5: NOKEY
  8. 准备中... ################################# [100%]
  9. 正在升级/安装...
  10. 1 :mysql-community-libs- 5.7. 23- 1.el7 ################################# [100%]
  11. [root@VM_0_16_centos mysql5. 7.23] # rpm -ivh mysql-community-client-5.7.23-1.el7.x86_64.rpm
  12. 警告:mysql-community-client- 5.7. 23- 1.el7.x86_64. rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072 e1f5: NOKEY
  13. 准备中... ################################# [100%]
  14. 正在升级/安装...
  15. 1 :mysql-community-client- 5.7. 23- 1.e ################################# [100%]
  16. [root@VM_0_16_centos mysql5. 7.23] # rpm -ivh mysql-community-server-5.7.23-1.el7.x86_64.rpm
  17. 警告:mysql-community-server- 5.7. 23- 1.el7.x86_64. rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072 e1f5: NOKEY
  18. 准备中... ################################# [100%]
  19. 正在升级/安装...
  20. 1 :mysql-community-server- 5.7. 23- 1.e ################################# [100%]

6.安装过程中可能出现的问题


 
 
  1. 1).缺少libaio
  2. [root@VM_0_16_centos mysql5 .7 .23]# rpm -ivh mysql-community- server -5.7 .17 -1.el7.x86_64.rpm
  3. 警告:mysql-community- server -5.7 .17 -1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
  4. 错误:依赖检测失败:
  5. libaio.so .1()( 64bit) 被 mysql-community- server -5.7 .17 -1.el7.x86_64 需要
  6. libaio.so .1(LIBAIO_0 .1)( 64bit) 被 mysql-community- server -5.7 .17 -1.el7.x86_64 需要
  7. libaio.so .1(LIBAIO_0 .4)( 64bit) 被 mysql-community- server -5.7 .17 -1.el7.x86_64 需要
  8. net-tools 被 mysql-community- server -5.7 .17 -1.el7.x86_64 需要
  9. 解决办法:
  10. [root@VM_0_16_centos mysql5 .7 .23]# yum install libaio

 
 
  1. 2)缺少net-tools
  2. [root@VM_0_16_centos mysql5 .7 .23]# rpm -ivh mysql-community- server -5.7 .17 -1.el7.x86_64.rpm
  3. 警告:mysql-community- server -5.7 .17 -1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
  4. 错误:依赖检测失败:
  5. net-tools 被 mysql-community- server -5.7 .17 -1.el7.x86_64 需要
  6. 解决办法:
  7. yum install net-tools

 
 
  1. 3)缺少numactl
  2. [root@VM_0_16_centos mysql5 .7 .23]# rpm -ivh mysql-community- server -5.7 .17 -1.el7.x86_64.rpm
  3. 报错:warning: mysql-community- server -5.7 .9 -1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
  4. error: Failed dependencies:
  5. libnuma.so .1()( 64bit) is needed by mysql-community- server -5.7 .9 -1.el6.x86_64
  6. libnuma.so .1(libnuma_1 .1)( 64bit) is needed by mysql-community- server -5.7 .9 -1.el6.x86_64
  7. libnuma.so .1(libnuma_1 .2)( 64bit) is needed by mysql-community- server -5.7 .9 -1.el6.x86_64
  8. 解决办法:
  9. yum install numactl

7.初始化数据库

[root@VM_0_16_centos mysql5.7.23]# mysqld --initialize  #初始化后会在/var/log/mysqld.log生成随机密码
 
 

8.修改mysql数据库目录的所属用户及其所属组,然后启动mysql数据库


 
 
  1. [ root@VM_0_16_centos mysql5.7.23] # chown mysql:mysql /var/lib/mysql -R
  2. [ root@VM_0_16_centos mysql5.7.23] # systemctl start mysqld.service
  3. [ root@VM_0_16_centos mysql5.7.23] # systemctl status mysqld.service
  4. ● mysqld.service - MySQL Server
  5. Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
  6. Active: active (running) since 一 2018 -08 -06 20: 41: 25 CST; 6s ago
  7. Docs: man:mysqld( 8)
  8. http: //dev.mysql.com/doc/refman/en/using-systemd.html
  9. Process: 13031 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/ var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status= 0/SUCCESS)
  10. Process: 13003 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status= 0/SUCCESS)
  11. Main PID: 13034 (mysqld)
  12. Tasks: 27
  13. CGroup: /system.slice/mysqld.service
  14. └─ 13034 /usr/sbin/mysqld --daemonize --pid-file=/ var/run/mysqld/mysqld.pid
  15. 806 20: 41: 22 eric111 systemd[ 1]: Starting MySQL Server...
  16. 806 20: 41: 25 eric111 systemd[ 1]: Started MySQL Server.

9.登录mysql,并修改root用户的密码(系统强制要求,否则不能操作mysql)

初始登录密码可在/var/log/mysqld.log文件中找到


 
 
  1. [root@VM_0_16_centos mysql5 .7 .23] # mysql -uroot -p'-4iq<tyjVpLb'
  2. mysql: [Warning] Using a password on the command line interface can be insecure.
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 2
  5. Server version: 5.7 .23
  6. Copyright (c) 2000, 2018, Oracle and/ or its affiliates. All rights reserved.
  7. Oracle is a registered trademark of Oracle Corporation and/ or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> set password=password( 'password11');
  12. Query OK, 0 rows affected, 1 warning ( 0.00 sec)
  13. mysql> show databases;
  14. +--------------------+
  15. | Database |
  16. +--------------------+
  17. | information_schema |
  18. | mysql |
  19. | performance_schema |
  20. | sys |
  21. +--------------------+
  22. 4 rows in set ( 0.00 sec)

10.修改访问权限

目的:任何主机通过用户root和密码password11连接到mysql服务器

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password11' WITH GRANT OPTION;
 
 

 

参考原文:

https://blog.csdn.net/tanjun592/article/details/71797972?locationNum=9&fps=1

https://blog.csdn.net/smiles13/article/details/81460617

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值