加强网站信息内容建设管理哈尔滨百姓网免费发布信息

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

加强网站信息内容建设管理,哈尔滨百姓网免费发布信息,华大基因 网站建设,深圳企业vi设计公司文章目录前言实验环境一. 安装MySQL1.1 配置yum源1.2 安装之前的环境检查1.3 下载MySQL的包1.4 开始使用yum安装1.5 启动并测试二. 设置新密码并重新启动2.1 设置新密码2.2 重新登录测试总结前言 学习MySQL是一件比较枯燥的事情#xff0c;学习开始之前要先安装MySQL数据库学习开始之前要先安装MySQL数据库之后才能进行增删改查和架构的搭建。 MySQL包含的内容比较多比如SQL语句的增删改查读写锁事务数据备份分库分表存储引擎和高可用优化等等。 专栏 【死磕数据库】是云计算架构专栏中的一个分专栏让我们一起学习数据库死磕数据库。 实验环境 本次实验是单台虚拟机上安装MySQL以下是简单的配置虚拟机使用的是vmware 刚开始学习的小伙伴建议与我的环境一致这样才好一起探讨学习呀。 操作系统 centos7.6IP地址 192.168.1.41内存 2GCPU 2C 提前关闭selinux和防火墙 [rootmufenggrow ~]# setenforce 0 [rootmufenggrow ~]# systemctl stop firewalld [rootmufenggrow ~]#
一. 安装MySQL 1.1 配置yum源 这里我们先备份 Centos-Base.repo,然后从阿里云下载centos7-repo 备份本地的yum源 [rootmufenggrow ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak下载阿里云的yum源 [rootmufenggrow ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo –2023-02-24 17:13:29– http://mirrors.aliyun.com/repo/Centos-7.repo 正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)… 120.192.91.238, 120.220.92.236, 120.220.92.240, … 正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|120.192.91.238|:80… 已连接。 已发出 HTTP 请求正在等待回应… 200 OK 长度2523 (2.5K) [application/octet-stream] 正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”100%[] 2,523 –.-K/s 用时 0.007s 2023-02-24 17:13:30 (338 KB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [25232523]) 1.2 安装之前的环境检查 在centos7的系统上默认是mariadb 如果要安装MySQL需要先把系统中存在的mysql或者mariadb删除掉。 查看是否已经安装MySQL/mariadb 如果已经安装先删除 [rootmufenggrow ~]# rpm -qa |grep mariadb mariadb-server-5.5.60-1.el7_5.x86_64 mariadb-libs-5.5.60-1.el7_5.x86_64 mariadb-5.5.60-1.el7_5.x86_64 [rootmufenggrow ~]# yum remove mariadb -y 再次查看是否还有残留如果有就删除 [rootmufenggrow ~]# rpm -qa |grep mysql qt-mysql-4.8.7-2.el7.x86_64 [rootmufenggrow ~]# rpm -e qt-mysql-4.8.7-2.el7.x86_64MySQL和mariadb都要查看 [rootmufenggrow ~]# rpm -qa |grep maraidb最后查看老版本中MySQL相关的安装目录 [rootmufenggrow ~]# find / -name mysql /etc/selinux/targeted/active/modules/100/mysql /usr/lib64/mysql /usr/lib64/perl5/vendor_perl/auto/DBD/mysql /usr/lib64/perl5/vendor_perl/DBD/mysql /usr/share/mysql [rootmufenggrow ~]# rm -rf /etc/selinux/targeted/active/modules/100/mysql [rootmufenggrow ~]# rm -rf /usr/lib64/mysql [rootmufenggrow ~]# rm -rf /usr/lib64/perl5/vendor_perl/auto/DBD/mysql [rootmufenggrow ~]# rm -rf /usr/lib64/perl5/vendor_perl/DBD/mysql [rootmufenggrow ~]# rm -rf /usr/share/mysql 1.3 下载MySQL的包 这里直接使用yum包所以下载rpm包生成yum包 在没下载安装之前我的系统中是没有MySQL相关的yum源的
下载MySQL57-community的rpm包 [rootmufenggrow yum.repos.d]# yum install wget -y wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm 这里我担心没有wget先安装wget再使用wget下载 使用rpm -ivh 安装刚刚下载的rpm包 [rootmufenggrow yum.repos.d]# rpm -ivh mysql57-community-release-el7-9.noarch.rpm 警告mysql57-community-release-el7-9.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 准备中… ################################# [100%] 正在升级/安装…1:mysql57-community-release-el7-9 ################################# [100%] 这时候会看到生成了几个与MySQL相关的repo的包 1.4 开始使用yum安装 直接使用yum安装即可 [rootmufenggrow yum.repos.d]# yum install mysql-community-server此处如果出现如下报错 mysql-community-libs-compat-5.7.41-1.el7.x86_64.rpm 的公钥尚未安装失败的软件包是mysql-community-libs-compat-5.7.41-1.el7.x86_64GPG 密钥配置为file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 只需要执行这条命令即可 rpm –import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022执行完成后重新进行安装 [rootmufenggrow yum.repos.d]# yum install mysql-community-server出现如图的内容表示安装成功 1.5 启动并测试 先启动然后查看运行状态 [rootmufenggrow yum.repos.d]# systemctl start mysqld [rootmufenggrow yum.repos.d]# systemctl status mysqld |grep activeActive: active (running) since 五 2023-02-24 18:17:05 CST; 22s ago [rootmufenggrow yum.repos.d]#
查看版本 [rootmufenggrow yum.repos.d]# mysql -V mysql Ver 14.14 Distrib 5.7.41, for Linux (x86_64) using EditLine wrapper 二. 设置新密码并重新启动 2.1 设置新密码 MySQL的密码并不是默认为空而是在启动的时候默认在log日志中生成密码可以通过命令查看到密码

grep temporary password /var/log/mysqld.log 随机密码超级难记我们可以设置自己的密码

先登录数据库 [rootmufenggrow yum.repos.d]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.41Copyright © 2000, 2023, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.Type help; or \h for help. Type \c to clear the current input statement.mysql
修改密码 mysql alter user rootlocalhost identified by Mufenggrow123!; Query OK, 0 rows affected (0.00 sec)mysql quit Bye 注意 这里的密码如果设置的过于简单也会报错要设置的复杂一点密码长度大于8位数 2.2 重新登录测试 [rootmufenggrow ~]# mysql -uroot -pMufenggrow123!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.41 MySQL Community Server (GPL)Copyright © 2000, 2023, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective

owners.Type help; or \h for help. Type \c to clear the current input statement.mysql create database mufeng;Query OK, 1 row affected (0.01 sec)mysql show databases;

Database
information_schema
mufeng
mysql
performance_schema
sys

5 rows in set (0.00 sec)mysql
可以看到数据库已经能够正常使用了接下来就开启MySQL学习之旅吧。 总结 好啦这就是今天要分享给大家的全部内容了我们下期再见 博客主页mufeng.blog.csdn.net 本文由沐风晓月原创首发于CSDN博客 每一个你想要学习的念头都是未来的你像现在的你求救不辜负未来全力奔赴