当前位置: 首页 > news >正文

yum安装MySQL数据库

yum安装方式

优点:操作简单易用。不用单独下载,服务器可以联网且yum源没有问题即可(可以选择国内的163/阿里源)

安装步骤:

1.关闭防火墙和selinux:

systemctl stop firewalld                 ##关闭防火墙
systemctl disable firewalld          ##禁止防火墙开机自启
setenforce  0                    ##关闭selinux
getenforce                     ##查看selinux状态

2.下载MySQL数据库的yum仓库

mysql的官方网站: www.mysql.com

[root@mysql-server ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

或者下载到本地上传到服务器

3,安装MySQL的yum仓库

[root@mysql-server ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm
[root@mysql-server ~]# yum -y install yum-utils    #安装yum工具包

4,配置yum厂库

vi /etc/yum.repos.d/mysql-community.repo 

在这里插入图片描述
1表示开启,0表示关闭

或者

yum-config-manager --enable mysql57-community   将禁用的yum源库启用
yum-config-manager --disable mysql80-community   将启用的yum源库禁用

5,安装MySQL数据库

[root@mysql-server ~]# yum install -y mysql-community-server
启动服务
[root@mysql-server ~]# systemctl start mysqld
设置开机启动
[root@mysql-server ~]# systemctl enable mysqld

6,查看系统设置的数据库密码并修改

密码保存在日志文件中
是root@localhost:后面的字符串

[root@mysql-server ~]# grep password /var/log/mysqld.log
2019-08-18T14:03:51.991454Z 1 [Note] A temporary password is generated for root@localhost: woHtkMgau9,w
修改密码:

两种方式:

第一种:
[root@mysql-server ~]# mysql -uroot -p'woHtkMgau9,w'
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 2
Server version: 5.7.27
....
mysql> alter user 'root'@'localhost' identified by 'QianFeng@123';
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
[root@mysql-server ~]# mysql -uroot -p'QianFeng@123'
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 3
Server version: 5.7.27 MySQL Community Server (GPL)
...
mysql> exit
Bye
第二种:
mysqladmin -u root -p'旧密码' password '新密码'
注:修改密码必须大小写数字和特殊符号都有。

7,修改弱密码

[root@mysql-server ~]# vim /etc/my.cnf   #在最后添加如下内容
validate_password=off
[root@mysql-server ~]# systemctl restart mysqld   #重启mysql生效
可以用第二种方式修改为简单的密码:
[root@mysql-server ~]# mysqladmin -uroot -p'QianFeng@123' password 'qf123'

相关文章:

  • MCP协议实战指南:在VS Code中实现PostgreSQL到Excel的自动化迁移
  • Unified Modeling Language,统一建模语言
  • centOS 安装和配置docker
  • 《探秘鸿蒙分布式软总线:开启无感发现与零等待传输新时代》
  • 3.7 字符串基础
  • 树莓派第5代主板连接cis摄像头
  • Python学习笔记(列表相关操作)
  • 供应商涨价,项目如何控制采购成本
  • ⑫交换机引流设备案例
  • What Was the “Game Genie“ Cheat Device, and How Did It Work?
  • ViT 模型讲解
  • 【Java八股】
  • 3.2.2.2 Spring Boot配置视图控制器
  • 机器学习项目三:颜色检测
  • Java老鼠迷宫(递归)---案例来自韩顺平老师讲Java
  • Neo4j GDS-11-neo4j GDS 库中相似度算法实现
  • 鸿蒙开发-ArkUi控件使用
  • 重学Redis:Redis常用数据类型+存储结构(源码篇)
  • 5.5 GitHub数据秒级分析核心揭秘:三层提示工程架构设计解析
  • 日志文件爆满_配置使用logback_只保留3天日志文件_每天定时生成一个日志文件---SpringCloud工作笔记206
  • 花3000元就能买“国际机构”的证书?揭秘假证产业链
  • 宁波一季度GDP为4420.5亿元,同比增长5.6%
  • 美元指数跌破98关口,人民币对美元即期汇率升值至4月3日来新高
  • “棉花糖爸爸”陈生梨:女儿将落户到贵州纳雍
  • 魔都眼|上海半马鸣枪:白金标运动员、“箱根之子”齐参赛
  • 廊坊市长:健全依法决策和决策纠错机制,把群众满意作为工作准绳