Linux中MySQL的安装以及卸载

一.MySQL

MySQL 是一种开放源代码的关系型数据库管理系统,开发者为瑞典MySQL AB公司。在2008年1月16号被Sun公司收购。而2009年,SUN又被Oracle收购.目前 MySQL被广泛地应用在Internet上的中小型网站中。由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,使得很多互联网公司选择了MySQL作为网站数据库(Facebook, Twitter, YouTube,阿里的蚂蚁金服,去哪儿,魅族,百度外卖,腾讯)。

关系数据库使用关系模型来组织数据。简单地说,关系模型指的是二维表模型。

[En]

Relational database uses relational model to organize data. to put it simply, relational model refers to two-dimensional table model.

非关系数据库可以看作是传统关系数据库的功能去势版本,它基于键-值对存储数据,并通过减少不常用的函数来提高性能。

[En]

Non-relational database can be regarded as the functional castrated version of traditional relational database, which stores data based on key-value pairs and improves performance by reducing rarely used functions.

关系型数据库设计规则:

遵循ER模型和三范式

  • E entity代表实体的意思 对应到数据库当中的一张表

  • R relationship代表关系的意思

三范式:1、列不能拆分 2、唯一标识 3、关系引用主键

具体体现:

*将数据放到表中,表再放到库中。

*一个数据库中可以有多个表,每个表都有一个名字,用来标识自己。表名具有唯一性。

*表具有一些特性,这些特性定义了数据在表中如何存储,类似java和python中 “类”的设计。

*表由列组成,我们也称为字段。每个字段描述了它所含有的数据的意义,数据表的设计实际上就是对字段的设计。创建数据表时,为每个字段分配一个数据类型,定义它们的数据长度和字 段名。每个字段类似java或者python中的”实例属性”。

*表中的数据是按行存储的,一行即为一条记录。每一行类似于java或python中的”对象”。

Linux中MySQL的安装以及卸载

二.MySQL的安装

1、关闭防火墙

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动

查看防火墙状态

firewall-cmd --state

启动防火墙

systemctl start firewalld.service

2、修改主机名

第一种

hostnamectl set-hostname base

第二种

vim /etc/hostname

查看主机名

hostnamectl status

3.安装MySQL

1)下载yum Repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

2)安装yum Repository

yum -y install mysql57-community-release-el7-10.noarch.rpm

3)安装mysql5.7

yum -y install mysql-community-server

4)开机自启动

systemctl enable mysqld.service

5)启动mysql

systemctl start mysqld.service

6)查看状态

systemctl status mysqld.service

7)获取临时密码

grep "password" /var/log/mysqld.log

8)登录mysql

mysql -uroot -p

9)关闭密码复杂验证

set global validate_password_policy=0;
set global validate_password_length=1;

10)设置密码

alter user user() identified by "123456";

11)修改权限

use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; --修改权限
flush privileges; --刷新权限
select host,user,authentication_string from user; --查看权限

12)卸载yum Repository
因为安装了Yum Repository,以后每次yum操作都会自动更新,需要把这个卸载掉:

yum -y remove mysql57-community-release-el7-10.noarch

三.MySQL的卸载

1.删除依赖包

rpm -qa |grep -i mysql
yum remove mysql-community mysql-community-server mysql-community-libs mysql-community-common

2.清理文件

find / -name mysql
rm -rf 文件名

Original: https://www.cnblogs.com/lmandcc/p/15224657.html
Author: lmandcc
Title: Linux中MySQL的安装以及卸载

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/508185/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球