当前位置:网站首页>Linux installation of MySQL (super detailed)
Linux installation of MySQL (super detailed)
2022-07-29 15:02:00 【Xiaofenxiong】
1 查看是否已经安装 Mysql
rpm -qa | grep mysql
I installed it once before!

如果你查看出来有东西,可以使用下面命令将其删除
rpm -e 文件名

2 下载官方 Mysql 包
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

如果安装有提示:Cannot write to ‘mysql57-community-release-el7-10.noarch.rpm’ (No such file or directory),那就是权限不够
可以输入 su root 来解决,然后重新下载.
3 安装MySQL包
yum -y install mysql57-community-release-el7-10.noarch.rpm

4 安装 MySQL
yum -y install mysql-community-server

如果执行命令过程中提示:Unable to find a match: mysql-community-server
则可以通过命令解决
yum module disable mysql
5启动 Mysql 服务
systemctl start mysqld.service

如果没有报错,进入第六步,
如果执行报错,多半是没有权限,执行下面语句赋予权限,然后重试
chown mysql:mysql -R /var/lib/mysql
6 查看 Mysql 运行状态
service mysqld status
Seeing this green means the startup is successful.
7 查看初始密码(红色部分为初始密码)
grep ‘password’ /var/log/mysqld.log

如果能正常查看到,则OK;如果查看不到,则表示没有密码.
8 进入数据库
mysql -u root -p
输入命令后,点击回车,会让你输入密码,然后输入刚刚的初始密码(输密码的时候不可见),当然支持粘贴,你可以复制初始密码后,然后粘贴.如果没有密码,直接回车即可.

注: If it shows that the database cannot be accessed

修改MySql配置文件my.cnf,新增skip-grant-tables
find / -name my.cnf

Remember to close the file before modifying itmysql服务
service mysqld stop
通过 vi Instructions go into the file

新增skip-grant-tables ,添加skip-grant-tables,这样mysql可以免密登录.

重启服务
service mysqld start
再次连接MySql,重置密码
Any password can be entered
mysql -u root -p


通过 show databases; 注意带 ; 号
show databases;

切换到mysql数据库

重置密码(为 root )
update user set authentication_string=password(‘root’) where user=‘root’;
修改配置文件my.cnf,删除skip-grant-tables,重启,再登录
删除skip-grant-tables

重启服务
service mysqld start
Enter by orderMySQL数据库
mysql -uroot -p

Log in again with the new password to get here!Linux 下 Mysql 安装到使用讲解完成!
【温馨提示】
如果本地访问Linux数据库失败,则记得看下下面三个配置是否OK.
(1)服务器的防火墙mysql端口3306是否开放
查看防火墙是否已开放3306端口
firewall-cmd --query-port=3306/tcp
设置3306端口为永久开放
firewall-cmd --add-port=3306/tcp --permanent
查看firewalld状态,发现当前是dead状态,即防火墙未开启
systemctl status firewalld
关闭防火墙
systemctl stop firewalld
重启防火墙(设置了新的端口记得先关闭,再重启)
systemctl status firewalld
(2)如果是阿里云ECS,记得查看云安全组规则是否开放了3306端口,如果没有,记得加上

(3)如果链接提示如下,则是没有允许远程登录

解决办法:
登录服务器mysql数据库
执行 use mysql;
执行 update user set host = '%' where user = 'root';
执行 FLUSH PRIVILEGES;

制作不易,Please give a thumbs up
边栏推荐
- Domestic mobile phones turn users into their advertising broilers, no wonder consumers are buying iPhones
- C语言 4:汇编语言指令介绍
- 城市污水处理过程模型预测控制研究综述
- 第4章_1——SQL语句实现MySQL增删改查
- 兆骑科创海外高层次人才引进平台,企业项目对接,赛事活动路演
- WOLFLAB一方老师带你解读虚拟云网络《VMware NSX-T卷2》-1
- EA&UML日拱一卒-活动图::Feature和StuctualFeature
- 换掉 UUID,更快、更安全!
- FPGA刷题——跨时钟域传输(FIFO+打拍+握手)
- 从一道面试题说起:GET 请求能传图片吗?
猜你喜欢

这 6 款在线 PDF 转换工具,得试

工作效率-十五分钟让你快速学习Markdown语法到精通排版实践备忘

C语言 3:常量和变量,顺序语句,选择语句,循环语句,作用域和生存期

双非渣渣的上岸之路!备战60天,三战滴滴侥幸收获Offer

ST表(动态规划倍增思路离线维护区间极值问题)

How to return all prime factors of a number?

基于C语言实现的LL(1)分析

Programmers are a group with a high incidence of occupational diseases. Don’t be naive to think that it’s just as simple as being bald.

威纶通触摸屏制作自定义欢迎界面的几种方法介绍

正斜杠 “/” 与反斜杠 “\”辨析
随机推荐
基于Flink CDC打通数据实时入湖
【左连接】坑点
arcgis中编码方式改变引起的shp文件乱码、字符截断问题处理
基于变胞机构的移动机器人构型设计研究综述
EA&UML日拱一卒-活动图::Variable Actions(续)
自定义fingerprint特征
这 6 款在线 PDF 转换工具,得试
rosbag数据画图MATLAB
上个厕所的功夫,就把定时任务的三种调度策略说得明明白白
Offensive EA&UML day arch - activity diagram: : Variable Actions (continue)
基于C语言仿真实现的粒子火焰系统
深开鸿:万物智联的大江上,升起一轮开源鸿蒙月
WOLFLAB一方老师带你解读虚拟云网络《VMware NSX-T卷2》-1
About inner classes
暴力递归到动态规划 02 (绝顶聪明的人的纸牌游戏)
题目 1125: C语言训练-委派任务*
打卡广汽本田喜悦安全驾驶中心,体验最刁钻的场地训练
三 RedisTemplate 序列化机制配置实战
测试日报怎么写 ?
【LeetCode】566. 重塑矩阵