当前位置:网站首页>腾讯云安装mysql数据库
腾讯云安装mysql数据库
2022-06-30 16:26:00 【twinkle||cll】
数据库迁移,记录下如何在新的服务器上安装mysql,方便自己的同时也来方便他人
1、卸载MariaDB
1、查看rpm -qa|grep mariadb
复制代码
2、卸载yum remove mariadb
复制代码
3、删除数据目录 rm -rf /var/lib/mysql/*
复制代码
4、删除配置文件rm -f /etc/my.cnf
复制代码
2.下载对应的包
========
- 下载并安装MySQL官方的 Yum Repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
复制代码
2.下载 MySQL 存储库配置
yum -y install mysql57-community-release-el7-10.noarch.rpm
复制代码
- 下载mysql服务
yum -y install mysql-community-server
复制代码
 出现这样的提示表示安装成功
安装不成功,
------
> 第三步安装的时候可能会报错,如下:

**解决办法如下:**
先执行: yum module disable mysql
再执行: yum install mysql-community-server
复制代码
> 然后就可以执行成功了
2. MySQL数据库设置
=============
- 查看mysql的位置
find / -name mysql
复制代码

> 出现如图的位置是mysql的默认安装位置
2.启动MySQL
systemctl start mysqld.service
复制代码
3.查看MySQL状态
systemctl status mysqld.service
复制代码
```

```
4.获取初始密码
grep "password" /var/log/mysqld.log
复制代码
```

```
5. 进入数据库修改密码
mysql -u root -p xxxxx,
然后执行:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password'
复制代码
```
这里有个问题,新密码设置的时候如果设置的过于简单会报错:

原因是因为MySQL有密码设置的规范,具体是与validate\_password\_policy的值有关:

**修改密码规则**
```
1. set global validate_password_policy=0;
2. set global validate_password_length=1;
复制代码
```
再重新设置密码
```
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
复制代码
```
退出重新登录
mysql -u用户名 -p密码
配置算是完成了
开放防火墙
=====
> 对于防火墙,大家都知道mysql的默认端口是3306,可以的话自己可以改一下。然后来开放端口。防止人家恶意攻击
```
1. 查看防火墙状态
systemctl status firewalld
复制代码
```

```
2. 启动防火墙
systemctl start firewalld
复制代码
```

```
3. 查看mysql的端口是否开放
firewall-cmd --zone=public --query-port=3306/tcp
// 开放的话结果是yes,否则是no
复制代码
- 开放端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
// 控制台会输出success
复制代码
5.重启防火墙
firewall-cmd --reload
//控制台输出sucess,就ok了
复制代码
```
可视化工具的登录授权
==========
> 是不是觉得,上面那些操作完成好后,就可以进行远程连接了,还不行呢
对远程客户端进行授权,否则就是连接失败,权限验证失败.
(1)SSH登录root管理员账户
(2)登录MySql
```
mysql -u root -p
Enter password:
复制代码
```
(3)执行授权命令
```
mysql> grant all privileges on *.* to [email protected]'localhost' identified by '密码';
mysql> flush privileges;
复制代码
```
或
```
mysql> grant all privileges on *.* to [email protected]'%' identified by '密码';
mysql> flush privileges;
复制代码
```
(4)退出再试
```
mysql> quit
Bye
复制代码
```
(5)再次登录
> 此后,数据库安装就完成了
边栏推荐
- Hyper-V: enable SR-IOV in virtual network
- Daily question brushing record (IX)
- Parker Parker sensor p8s-grflx
- Parker proportional overflow valve rs10r35s4sn1jw
- Tubes响应性数据系统的设计与原理
- Bridge emqx cloud data to AWS IOT through the public network
- 如何写一个技术方案
- The gates of Europe
- [zero basic IOT pwn] environment construction
- Servlet operation principle_ API details_ Advanced path of request response construction (servlet_2)
猜你喜欢
Six photos vous montrent pourquoi TCP serre la main trois fois?
Cesium-1.72 learning (model attitude control)
Cesium-1.72 learning (earth rotation)
Canvas mouse control gravity JS effect
Cesium-1.72 learning (eagle eye map of the earth)
New skill: accelerate node through code cache JS startup
ROC-RK3566-PC使用10.1寸IPS触摸屏显示
A tough battle for Tencent cloud
[Architecture] 1366- how to draw an excellent architecture diagram
canvas云朵形状动画
随机推荐
How can you choose to work in the county after graduation?
编写C语言的最简单小程序Hello world
[零基础学IoT Pwn] 环境搭建
如何写一个技术方案
canvas鼠标控制重力js特效
Unity particle_ Exception display processing
Network: principle and practice of server network card group technology
流批一体在京东的探索与实践
Booking UI effect implemented by svg
5G业务正式商用,属于广电的机会在哪?
Advanced Mathematics (Seventh Edition) Tongji University General exercises one person solution
[untitled] write a student achievement and information management system in C language to realize the operation interface, clear screen display of current operation functions, reading and inputting st
4 years of working experience, and you can't tell the five communication modes between multithreads. Can you believe it?
开发那些事儿:如何在视频中添加文字水印?
商鼎云新版来袭 | 收藏夹功能已上线,满足个人使用需求
splitting. JS password display hidden JS effect
Course design for the end of the semester: product sales management system based on SSM
Interview shock 60: what will cause MySQL index invalidation?
Exch:修复丢失的系统邮箱
Login box tricks