当前位置:网站首页>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

边栏推荐
- 数组操作——判断、去重、合并、展开
- 小程序嵌入网页向小程序跳转并传参,微信小程序中实现公众号授权获取openId
- uni scroll-view 下拉刷新
- Cve-2022-34265 Django extract & TRUNC SQL injection vulnerability recurrence
- Supplementary knowledge of attributes and methods of regular, JWT token, ronglianyun, celery, channel group, SKU, SPU, request object
- About foreign key references, cross domain headers, and ref usage
- Applet swiper height
- js替换字符串某个字符,js修改字符串中指定字符
- (七)流程控制
- uni-app微信小程序——商城(7)——商品详情
猜你喜欢

If the website is hacked, what if you jump to other websites through Baidu / Sogou and other search keywords?

uni-app微信小程序——商城(3)——商城主页
![[elementui El date picker date selector, the end time must not be earlier than the start time, and only the date of the specified number of days from the start time can be selected]](/img/73/af7ca3f670ffee18081b9ca6a9ccf6.png)
[elementui El date picker date selector, the end time must not be earlier than the start time, and only the date of the specified number of days from the start time can be selected]

分布式之数据库和缓存双写一致性方案解析(转载)

let和const、let、const和var的区别

Use leaflet to copy the original shentiwa Mega map to make a diary

【ElenmentUI el-date-picker日期选择器,结束时间不得早于开始时间,且只能选择距开始时间指定天数的日期】

JS intercepts the first few digits of the string or the last few digits of the string

JS get the suffix format of a file name

Uni app wechat applet - Mall (4) - merchants
随机推荐
使用redis - zset做排行榜
分布式之数据库和缓存双写一致性方案解析(转载)
es可选链
Replace special characters in URL (%e2%80%8b)
智能指针(shared_ptr、unique_ptr、weak_ptr)
今天的码农女孩做了关于生命周期的笔记以及动态时钟的练习
markdown编辑器语法——文字颜色、大小、字体与背景色的设置(转载)
今天的码农女孩做了关于呼吸灯的练习、受控组件和高阶组件的简答题
uniapp开发App中上传图片直传oss
Cve-2022-34265 Django extract & TRUNC SQL injection vulnerability recurrence
PCRE bypasses regular
Uniapp calls the map to query the location and mark the location
05_回顾Object.defineProperty
uniapp调用地图,进行位置查询,标记定位
Uni app wechat official account (4) - address management page
C Programming Language (2nd Edition)--读书笔记--1.5.2
使用bat自动执行cmd命令(多个命令或单个命令)
网站如何统计访问人数?51LA如何安装使用?
Vue项目部署,清理缓存
JS get the suffix format of a file name