当前位置:网站首页>Linux之yum安装MySQL
Linux之yum安装MySQL
2022-07-28 22:17:00 【鹅鹅鹅呢】
文章目录
Linux之yum安装MySQL
部署MySQL数据库有多种部署方式,常用的部署方式就有三种:yum安装、rpm安装以及编译安装。每一种安装方式都有自己的优势,那么企业当中通常情况下采用的是rpm和二进制安装的方式。
Mysql 5.7的主要特性
更好的性能:对于多核CPU、固态硬盘、锁有着更好的优化,每秒100W QPS已不再是MySQL的追求,下个版本能否上200W QPS才是吾等用户更关心的
更好的InnoDB存储引擎
更为健壮的复制功能:复制带来了数据完全不丢失的方案,传统金融客户也可以选择使用MySQL数据库。此外,GTID在线平滑升级也变得可能
更好的优化器:优化器代码重构的意义将在这个版本及以后的版本中带来巨大的改进,Oracle官方正在解决MySQL之前最大的难题
原生JSON类型的支持
更好的地理信息服务支持:InnoDB原生支持地理位置类型,支持GeoJSON,GeoHash特性
新增sys库
yum部署方式
从CentOS 7.0发布以来,yum源中开始使用Mariadb来代替MySQL的安装(这里什么是mariadb,和mysql有什么区别,有兴趣的小伙伴可以自行查阅)。即使你输入的是yum install -y mysql , 显示的也是Mariadb的安装内容。如果想安装Mysql就必须使用Mysql官方的yum源。
1、编写yum源配置文件
#配置好yum源,包括epel源
1. curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
2. wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
3. yum -y install vim wget
使用官方yum仓库


wget https://dev.mysql.com/get/mysql80-community-release-el7-4.noarch.rpm(复制下来的链接)

yum install mysql80-community-release-el7-4.noarch.rpm
2、生成yum源缓存
每次当我们编写了,都需要生成yum缓存,以免安装错误。
1. yum makecache
3、检查安装的yum源是否存在
1. yum repolist enabled | grep mysql
选择默认安装的版本 默认的是8.0 版本
安装 YUM 管理工具包,此包提供了 yum-config-manager 命令工具
1. yum -y install yum-utils
2. yum-config-manager --disable mysql80-community
3. yum-config-manager --enable mysql57-community
4. yum repolist enabled | grep mysql

4、安装MySQL服务
yum install -y mysql-community-server 然后等待安装即可
5、启动MySQL服务
启动mysqld 服务端
1. systemctl start mysqld
查看是否启动
2. systemctl status mysqld

6、初始化
MySQL服务器初始化(从MySQL 5.7开始)
在 MySQL 服务器初始启动时,如果服务器的数据目录为空,则会发生以下情况:
MySQL 服务器已初始化。
在数据目录中生成SSL证书和密钥文件。
安装并启用该 validate_password 插件。
将创建一个超级用户 帐户’root’@‘localhost’。并会设置超级用户的密码,将其存储在错误日志文件/var/log/mysqld.log中。
- grep ‘temporary password’ /var/log/mysqld.log

7、尝试连接并修改默认密码
mysql -uroot -p'goUaahghs8?r'

# 出现以下错误的原因是需要修改初始化密码
1. show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
2. alter user [email protected] identified by '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
#太过简单的密码会失败,因为不满足密码复杂度的要求
# 修改密码
1. alter user [email protected] identified by '[email protected]';
Query OK, 0 rows affected (0.00 sec)
# 刷新权限
2. FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
# 要设置比较简单的密码就需要取消密码复杂度,编辑 /etc/my.cnf配置文件, 在 [mysqld]配置块儿中添加如下内容(企业生成环境不建议使用这种配置)
plugin-load=validate_password.so
validate-password=OFF
8、远程连接
远程登录还需要授权远程登录
Mysql默认不允许远程登录,我们需要设置关闭selinux或者防火墙,不关防火墙就开放3306端口;
# 允许本地用户链接
1. grant all privileges on *.* to [email protected] identified by '密码';
Query OK, 0 rows affected, 1 warning (0.00 sec)
# 允许任意IP连接
2. grant all privileges on *.* to [email protected]'%' identified by '密码';
Query OK, 0 rows affected, 1 warning (0.00 sec)
添加开放3306端口的iptables规则
iptables -t filter -I INPUT -p tcp --dport 3306 -j ACCEPT
卸载已经安装的MySQL
//rpm包安装方式卸载
查包名:rpm -qa|grep -i mysql
删除命令:rpm -e –nodeps 包名
//yum安装方式下载
1.查看已安装的mysql
命令:rpm -qa | grep -i mysql
2.卸载mysql
命令:yum remove mysql-community-server-5.6.36-2.el7.x86_64
查看mysql的其它依赖:rpm -qa | grep -i mysql
//卸载依赖
yum remove mysql-libs
yum remove mysql-server
yum remove perl-DBD-MySQL
yum remove mysql
下一篇>>>MySQL数据库基本管理
边栏推荐
- Leetcode 763. partition labels divide alphabetic intervals (medium)
- PowerCL 批量创建及管理虚拟交换机
- What is a driver signature and how does the driver get a digital signature?
- DoIP测试开发实践
- Pycharm new project
- 多传感器融合定位(一)——3D激光里程计
- leetcode 763. Partition Labels 划分字母区间(中等)
- Working principle of fastdfs (technical principle)
- GhostNets on Heterogeneous Devices via Cheap Operations
- Zabbix 5.0 使用自带Redis模版监控
猜你喜欢

控件 圆角描边 MaterialShapeDrawable

【详细超简单】如何使用WebSocket链接

Use pytoch to quickly train the network model

After SAP Oracle replicates a new instance, the remote connection of the database reports an error ora-01031

【C】替换空格,宏实现整数的二进制奇偶位交换

PHP 海报二维码合成

Multi sensor fusion positioning (II) -- map based positioning

多传感器融合定位(三)——惯性技术

GhostNets on Heterogeneous Devices via Cheap Operations

Leetcode59. 螺旋矩阵 II
随机推荐
PowerCLi VMware vCenter 通过自建的PXE Server一键批量部署常规New-VM
[TA frost wolf \u may - "hundred people plan"] Figure 3.6 texture compression - inclusion slimming
Is the declarative code of compose so concise?
1-4 类的复习
Pycharm new project
PowerCL 批量创建及管理虚拟交换机
实时数仓:美团点评Flink的实时数仓应用分享
Jincang database kingbasees client programming interface guide ODBC (5. Development process)
基因组 DNA 分离丨Worthington核糖核酸酶A
VirtualLab基础实验教程-8.傅里叶变换(1)
Use pytoch to quickly train the network model
PHP poster QR code synthesis
Word中的\n是什么?:^p
[detailed and super simple] how to use websocket links
你知道有哪些正规的兼职平台吗?
VMware VCSA 7.0 Install
Worthington丨STEMxyme的分类和测定方法
JS高级 之 ES6~ES13 新特性
Arm-a53 data "recommended collection"
DoIP测试开发实践