当前位置:网站首页>Cento7安装mysql5.5以及升级5.7
Cento7安装mysql5.5以及升级5.7
2022-07-17 00:07:00 【誓下】
1、配置好yum源

2、 yum install -y mariadb-server mariadb 下载mariadb

3、启动数据库,并且开机自启
[[email protected] ~]# systemctl start mariadb [[email protected] ~]# systemctl status mariadb
4、mysql_secure_installation #安全配置初始化
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here.
Enter current password for root (enter for none): #请输入root密码,因为我们之前没有密码,所以这里直接回车
Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation.
Set root password? [Y/n] #是否要设置root密码 New password: #输入两次密码 Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.
Remove anonymous users? [Y/n] #是否移除匿名用户,为了数据库安全起见,选择y
Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] #是否允许root远程登录,要选择y,不然不能通过第三方软件进行登录
By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.
Remove test database and access to it? [Y/n] #是否要移除测试库,为了安全起见,选择y
Dropping test database... ... Success!
Removing privileges on test database... ... Success!
Reloading the privilege tables will ensure that all changes made so far will take effect immediately.
Reload privilege tables now? [Y/n] #是否要更新权限表,一定要选择更新 y ... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB installation should now be secure.
Thanks for using MariaDB!
5、登录:

6、create database jisuanji #创建一个数据库

7、create table test( name varchar(15) ,age int ,password varchar(15)); #创建表并且添加字段:
8、update mysql.user set Host='%' where Host='localhost'; //修改连接的权限,%代表所有ip
flush privileges; //更新
9、给表填充内容
insert into test values('xxxx',99,'123456');

10、 mysqldump -uroot -p -B jisuanji -T test >/opt/test.sql #把计算机这个库的内容导出来
cat /opt/test.sql
-- MySQL dump 10.14 Distrib 5.5.68-MariaDB, for Linux (x86_64)
-- Host: localhost Database: jisuanji
-- Server version 5.5.68-MariaDB
/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */; /*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */; /*!40101 SET @[email protected]@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @[email protected]@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @[email protected]@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @[email protected]@SQL_NOTES, SQL_NOTES=0 */;
--
-- Current Database: jisuanji
CREATE DATABASE /*!32312 IF NOT EXISTS*/ jisuanji /*!40100 DEFAULT CHARACTER SET latin1 */;
USE jisuanji;
--
-- Table structure for table test
DROP TABLE IF EXISTS test;/*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE test ( name varchar(15) DEFAULT NULL, age int(11) DEFAULT NULL, password varchar(15) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table test
LOCK TABLES test WRITE;/*!40000 ALTER TABLE test DISABLE KEYS */; INSERT INTO test VALUES ('zhangsijin',99,'123456'); /*!40000 ALTER TABLE test ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET [email protected]_TIME_ZONE */;
/*!40101 SET [email protected]_SQL_MODE */; /*!40014 SET [email protected]_FOREIGN_KEY_CHECKS */; /*!40014 SET [email protected]_UNIQUE_CHECKS */; /*!40101 SET [email protected]_CHARACTER_SET_CLIENT */; /*!40101 SET [email protected]_CHARACTER_SET_RESULTS */; /*!40101 SET [email protected]_COLLATION_CONNECTION */; /*!40111 SET [email protected]_SQL_NOTES */;
-- Dump completed on 2022-07-04 22:48:34
11、下载SQL5.7
删除mariadb
rpm -qa | grep mysql && rpm -qa|grep mariadb //查找
rpm -e --nodeps XXXXXX //删除,如rpm -e --nodeps mariadb-*
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm yum -y localinstall mysql80-community-release-el7-3.noarch.rpm vi /etc/yum.repos.d/mysql-community.repo
把5.7的enabled修改为1,把8.0的修改为0。如果想下载其他版本也可以把它置为1,其余为0
把gpgcheck修改为0,否则可能会出现密匙什么公匙未安装,不适合等问题



数据库导入的时候一定要与USE字段的数据库名一样,否则无法导入。
mysql -uroot -p123456 wanggong< /opt/test.sql

边栏推荐
- markdown编辑器语法——文字颜色、大小、字体与背景色的设置(转载)
- Uni app wechat official account (4) - address management page
- JSX syntax
- elemtnui 表格如何修改某行文字颜色(elemtnui table 修改某行文字颜色)
- uni-app微信小程序——商城(7)——商品详情
- 量化行业知识汇总
- Uni app wechat applet - Mall (6) - my home page
- Cve-2022-34265 Django extract & TRUNC SQL injection vulnerability recurrence
- JSX 语法
- [GFCTF 2021]Baby_ Cve-2021-41773 on the web
猜你喜欢

JSX syntax

tp-watermark. JS web page add watermark plug-in

使用leaflet仿原神提瓦特大地图制作日记

wget 警告: 无法验证

Nodejs cross domain CORS

XSS simple summary

From catf1ag two-hour AK match pwn/attack killing, summarize the common command guide of emergency response

Page layout - three column layout solution

tp-watermark.js网页添加水印插件

Self encapsulated stylized switch card assembly
随机推荐
今天的码农女孩总结了jQuery处理缓存的方法和事件委托方法的区别的笔记
Promise的基本使用
使用leaflet仿原神提瓦特大地图制作日记
页面布局——三栏布局解决方式
服务器如何安装宝塔面板?(宝塔面板安装教程)
promise
网站被黑,通过百度/搜狗等搜索关键词访问跳转到其他网站怎么办?
extern和static的区别
05_回顾Object.defineProperty
uni-app微信小程序——商城(4)——商家
uniapp调用地图,进行位置查询,标记定位
(六)test命令
v-cloak与v-bind绑定class
es6语法--解构赋值
今天的码农女孩学习了关于事件操作和ref属性的笔记并做了表单双向绑定的练习
The C Programming Language (2nd)--笔记--1.6
单页面应用 SPA 和多页面应用 MPA
JSX compilation
判断两个时间戳是否是同一天
Moveit2——1.开始