惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 【当耐特】
M
MIT News - Artificial intelligence
罗磊的独立博客
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Stack Overflow Blog
Stack Overflow Blog
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
Security Archives - TechRepublic
Security Archives - TechRepublic
宝玉的分享
宝玉的分享
N
News and Events Feed by Topic
The Hacker News
The Hacker News
Google DeepMind News
Google DeepMind News
C
CERT Recently Published Vulnerability Notes
F
Full Disclosure
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Security @ Cisco Blogs
H
Hacker News: Front Page
L
LangChain Blog
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
B
Blog RSS Feed
H
Heimdal Security Blog
Google Online Security Blog
Google Online Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 三生石上(FineUI控件)
V2EX - 技术
V2EX - 技术
V
Vulnerabilities – Threatpost
Help Net Security
Help Net Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
Tailwind CSS Blog
W
WeLiveSecurity
T
Tenable Blog
D
DataBreaches.Net
Martin Fowler
Martin Fowler
Cyberwarzone
Cyberwarzone
Cisco Talos Blog
Cisco Talos Blog
S
Secure Thoughts
O
OpenAI News
L
LINUX DO - 热门话题
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
Jina AI
Jina AI
J
Java Code Geeks
Know Your Adversary
Know Your Adversary
IT之家
IT之家
Latest news
Latest news
Cloudbric
Cloudbric

博客园 - 倾听-静轩水月

Mysql优化笔记 Arthas使用 vue2.0和vue3.0同时使用 零基础尝试mybatis-plus读写分离 零基础尝试搭建docker和nacos环境 零基础尝试mysql主从复制 mybatis-plus 批量插入示例 找回windows应用商店 linux 开放端口 http转向https 内存不够导致编译报错:Information:java: java.lang.OutOfMemoryError: GC overhead limit exceeded docker常用命令 CentOS7使用命令行安装Oracle11GR2 使用Xshell连接VMware上的Linux虚拟机 mysql免安装版初次使用 微信小程序支付证书及SSL证书使用 SqlServer无备份下误删数据恢复 javaweb学习--javabean javaweb学习--jsp
小白零基础在 Centos 7 中安装 mysql
倾听-静轩水月 · 2023-05-22 · via 博客园 - 倾听-静轩水月

本文参考这三篇博文,安装修改配置修改密码。感谢大佬的分享

首先安装好Centos,并使用xshell连接

一、下载

   1、下载安装文件

       建议自己到这个地址下载 https://dev.mysql.com/downloads/mysql/。选择以下版本

  2、下载完后上传到系统,并解压,可以用  tar -xvf 命令解压。解压完后有下面几个文件

       

二、安装

   1、检查系统中是否已经安装了mysql      

        如果有,则用下面这个命令卸载 

yum remove mariadb-libs-5.5.52-1.el7.x86_64 -y

        再使用上面的命令检查,直到没有为止

     2、按下面的几个命令,逐个执行安装     


rpm -ivh mysql-community-common-8.0.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.32-1.el7.x86_64.rpm
yum -y install perl.x86_64 //这步看情况,没报错的话就不用
yum -y install net-tools.x86_64 //这步看情况,没报错的话就不用
rpm -ivh mysql-community-server-8.0.32-1.el7.x86_64.rpm


        3、安装完成后,用下面的命令,查看版本号

   3.1、插一个要点,如果是高版本,以当前文章安装版本为例,默认区分大小写,需要在 my.cnf  文件先配置好如下参数

lower_case_table_names = 1

      3.2、插一个点,批量操作数据的时候,会提示数据太长,则可以修改  my.cnf 文件里配置 如下参数

max_allowed_packet = 200M

          注意,这个参数的最大值为 1 G

   4、启动mysql服务 注意:到这步千万别轻易修改 /etc/my.cnf 文件,容易出现启动不了的现象

== 每次开机都要手动启动mysql ==
systemctl start mysqld
== 开机时自动开启mysql ==
systemctl enable mysqld
== 停止mysql服务器==
service mysqld stop
==启动mysql服务器==
service mysqld start
== 查看mysql是否启动==
service mysqld status

三、登录及修改密码

    1、查找默认密码

          定位到 /var/log 中,使用命令     

grep -n password mysqld.log

          展示为:[Note] A temporary password is generated for root@localhost: 0x(g<n074&7W  ,加粗部分即为临时密码

     2、使用默认密码登录

           如果出现 mysql>  则登录成功

     3、修改配置

         先把密码修改成临时的密码,尽量复杂一些

mysql> alter user 'root'@'localhost' identified by 'qaz,WSX_123456';

         查看mysql默认配置 

mysql> SHOW VARIABLES LIKE 'validate_password%';

         使用以下命令修改密码强度要求(0或low代表最低要求)

mysql> set global validate_password.policy=0;  #如果不行,就用下面这个
mysql> set global validate_password.policy=LOW;

         修改密码长度要求

mysql> set global validate_password.length=8;

      4、修改密码

mysql> alter user 'root'@'localhost' identified by '12345678';

      5、允许远程连接

           显示数据库信息     

           切换使用mysql库    

       修改允许远程连接

mysql> update user set host = '%' where user='root';
mysql> flush privileges;

           至此,mysql可以正常使用了