首页 > 数据库 >centos7.6 安装 mysql5.7

centos7.6 安装 mysql5.7

时间:2022-10-04 22:44:59浏览次数:77  
标签:新密码 rpm mysql5.7 MySQL yum mysql password 安装 centos7.6

卸载mariadb

rpm -qa | grep mariadb

rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64 //名称会有变

CentOS 7.6 内部集成了mariadb,而安装mysql的话会和mariadb的文件冲突,所以需要先卸载掉mariadb。

步骤一:更新YUM源

运行以下命令添加epel源。 yum install  https://repo.ius.io/ius-release-el7.rpm  https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

步骤二:安装MySQL

运行以下命令更新YUM源。 rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

查看各版本启动状况

yum repolist all | grep mysql

 

 

 禁用8.0,开启5.7

您需要先运行命令yum module disable mysql禁用默认的MySQL模块,再安装MySQL。

yum-config-manager --disable mysql80-community

yum-config-manager --enable mysql57-community

命令在yum-utils 包里,安装既可以解决无法找到yum-config-manager命令:

yum -y install yum-utils

安装mysqll

yum -y install mysql-community-server

运行以下命令查看MySQL版本号。

mysql -V

返回结果如下所示,表示MySQL安装成功。

mysql Ver 14.14 Distrib 5.7.36, for Linux (x86_64) using EditLine wrapper

运行以下命令启动Mysql

systemctl start mysqld

依次运行以下命令设置开机启动Mysql

systemctl enable mysqld systemctl daemon-reload

查看默认生成密码

grep 'temporary password' /var/log/mysqld.log

运行以下命令配置MySQL的安全性。

mysql_secure_installation

输入MySQL的初始密码。
说明 在输入密码时,系统为了最大限度的保证数据安全,命令行将不做任何回显。您只需要输入正确的密码信息,然后按Enter键即可。

为MySQL设置新密码。

The existing password for the user account root has expired. Please set a new password.  
New password: #输入新密码。长度为8至30个字符,必须同时包含大小写英文字母、数字和特殊符号。特殊符号包含()` ~!@#$%^&*-+=|{}[]:;‘<>,.?/  

Re-enter new password: #确认新密码。 
The 'validate_password' plugin is installed on the server. 
The subsequent steps will run with the existing configuration 
of the plugin. Using existing password for root. 
Estimated strength of the password: 100#返回结果包含您设置的密码强度。 
Change the password for root ? ((Press y|Y for Yes, any other key for No) :Y #您需要输入Y以确认使用新密码。#新密码设置完成后,需要再次验证新密码。 
New password:#再次输入新密码。  Re-enter new password:#再次确认新密码。 
Estimated strength of the password: 100 Do you wish to continuewith the password provided?(Press y|Y for Yes, any other key for No) :Y #您需要输入Y,再次确认使用新密码。

输入Y删除匿名用户。

Removeanonymoususers?(Pressy|YforYes,anyotherkeyforNo):Y
Success.

输入Y禁止使用root用户远程登录MySQL

Disallowrootloginremotely?(Pressy|YforYes,anyotherkeyforNo):Y
Success.
Disallowrootloginremotely?(Pressy|YforYes,anyotherkeyforNo):Y Success.

  

Remove test database and access to it? (Press y|Y for Yes, any other key for No) :Y  
- Dropping test database... Success.   
- Removing privileges on test database... Success.

输入Y重新加载授权表。

Reloadprivilegetablesnow?(Pressy|YforYes,anyotherkeyforNo):Y
Success.All done!

 

 

另一种修改root密码

登录修改密码

mysql -uroot -p

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NoPassword564925080!';

 

授权远程登录用户

GRANT ALL PRIVILEGES ON *.* TO 'noneplus'@'%' IDENTIFIED BY 'Noneplus564925080!' WITH GRANT OPTION; flush privileges;

标签:新密码,rpm,mysql5.7,MySQL,yum,mysql,password,安装,centos7.6
From: https://www.cnblogs.com/wangfx/p/16754695.html

相关文章

  • Windows下安装与配置Docker
    1、Windows相关    启用虚拟化,打开任务管理器,性能,查看虚拟化是否已启用,如下图所示:    启用Hyper-v,打开控制面板,启用或关闭Windows功能,勾选Hyper-v,确定即可(......
  • Docker安装Portainer
    Docker安装PortainerDocker介绍Docker是一个开源的容器引擎,完全使用沙箱机制,相互之间不会有任何接口,并且容器性能开销低,让开发者可以打包应用或者依赖包到一个可移植的......
  • keepalived的安装和配置
    主机名称服务器IPserver0110.1.1.3masterserver0210.1.1.4backup第一步:master和backup都进行安装keepalivedyum-yinstallkeepalived文件或者目录作用/etc/keepalived/ke......
  • 安装Docker容器时,出现https://yum.dockerproject.org/repo/main/centos/7/repodata/re
    解决办法:首先确定把相应的前置包都安装好,之后操作命令行:执行yum-config-manager--disabledockerrepo命令然后再执行:sudo yum installdocker-cedocker-ce-clicont......
  • MySQL-8.0.11安装教程-windows
    1.下载解压版:https://downloads.mysql.com/archives/installer/2.解压3.配置...\mysql-8.0.11-winx64\bin路径变量进path4.在解压目录配置my.ini[client]#设置mysql......
  • 记一次在ubuntu安装filewall遇到的缺少包的错误解决方案,备用
    折腾了将近8个小时,网上找遍了,才找到这个方法,记录备用,方法纯于照搬提示:Youmightwanttorun'apt--fix-brokeninstall'tocorrectthese.Thefollowingpackage......
  • docker 安装 redis
    docker安装redis[root@localhost~]#dockerpullredis:latest#最新版本的镜像latest:Pullingfromlibrary/redisDigest:sha256:db485f2e245b5b3329fdc7eff4eb0......
  • python在没有公网的情况下pip安装离线包
    首要条件是找一台可以连接公网的服务器。1、生成requirements.txtpip3freeze>requirements.txt2、创建本地仓库repodatamkdir./repodata3、拉取离线whl包pi......
  • docker安装linux镜像制作,制作Docker镜像的两种方式
    dockertagyuanhuan/newcontainer1docker账号名称/dev:77dockerpushdocker账号名称/dev:77转载自:https://blog.csdn.net/weixin_39821604/article/details......
  • Ubuntu 20.04中安装使用SQLite3
      1.Ctrl-Alt-T打开终端2.安装sqlite3sudoapt-getinstallsqlite3libsqlite3-dev3.创建数据库sqlite3mysqlite.db4.创建数据表CREATETABLEmyTable(idINT......