当前位置:网站首页>腾讯云安装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)再次登录
> 此后,数据库安装就完成了
边栏推荐
- [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
- Horizontal visual error effect JS special effect code
- Cesium-1.72 learning (eagle eye map of the earth)
- canvas云朵形状动画
- Cesium-1.72 learning (model attitude control)
- 商鼎雲新版來襲 | 收藏夾功能已上線,滿足個人使用需求
- parker比例溢流阀RS10R35S4SN1JW
- flutter 音乐 录音 播放 audioplayers
- IEEE TBD SCI影响因子提升至4.271,位列Q1区!
- 应届生毕业之后先就业还是先择业?
猜你喜欢

将 EMQX Cloud 数据通过公网桥接到 AWS IoT

Canvas mouse control gravity JS effect

腾讯云的一场硬仗

自旋锁探秘

Develop those things: how to add text watermarks to videos?

The new version of Shangding cloud | favorites function has been launched to meet personal use needs

Booking UI effect implemented by svg

Parker Parker sensor p8s-grflx

Cloud practice of key business migration of Internet of things by well-known Internet housing rental service companies

商鼎雲新版來襲 | 收藏夾功能已上線,滿足個人使用需求
随机推荐
网络:服务器网卡组技术原理与实践
[proteus simulation] Arduino uno uses 74ls148 to extend interrupt
Building a basic buildreoot file system
每日刷题记录 (九)
Shutter music recording playing audioplayers
TFTP下载kernel,nfs挂载文件系统
Flutter custom component
数据中心的能耗焦虑, 到底有没有最优解?
[Architecture] 1366- how to draw an excellent architecture diagram
MySQL advanced notes
svg实现的订票UI效果
力士乐液控单向阀Z2S10-1-3X/
万卷书 - 书单整理 [01]
K-line diagram interpretation and practical application skills (see position entry)
自旋锁探秘
Share 5 commonly used feature selection methods, and you must see them when you get started with machine learning!!!
Radio and television 5g officially set sail, attracting attention on how to apply the golden band
Cesium-1.72 learning (eagle eye map of the earth)
墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
leetcode:787. The cheapest transfer flight in station K [k-step shortest path + DFS memory + defaultdict (dict)]