笔记本电脑Linux咔咔咔声音,【Mysql】Linux编辑安装

author:咔咔

wechat:fangkangfk

这里就是会遇到设置密码问题,这个问题,我在下面文章已经写了,可以看,如果是不需要修改密码的,就不用管了

从CentOS 7.0发布以来,yum源中开始使用mariadb来代替MySQL的安装。即使你输入的是yum install mysql , 显示的也是mariadb的安装内容。

首先先卸载mariadb。

检查mariadb是否已安装

1

2

[root@localhost ~]# yum list installed | grep mariadb

mariadb-libs.x86_64                  1:5.5.56-2.el7                    @anaconda

全部卸载

26e78a3d428f4504a5973d619ad9e43d.png 卸载默认安装的mariadb

安装Mysql

一、下载安装官方提供的yum rpm包

点击Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package后面的download,进入新的页面点击No thanks, just start my download.就可以看到下载源地址了。

下载wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

1

wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

安装rpm包

1

rpm -ivh mysql80-community-release-el7-1.noarch.rpm

检查mysql的yum源是否安装成功:yum repolist enabled | grep "mysql.*-community.*"

1

2

3

4

[root@localhost src]# yum repolist enabled | grep"mysql.*-community.*"

mysql-connectors-community/x86_64       MySQL Connectors Community           51

mysql-tools-community/x86_64            MySQL Tools Community                63

mysql80-community/x86_64                MySQL 8.0 Community Server           17

二、使用yum install mysql-server安装(这里会有点慢)

1

yum -y  install mysql-server

26e78a3d428f4504a5973d619ad9e43d.png 查看版本信息

三、启动mysql

1

2

[root@localhost ~]# service mysqld start

Redirecting to /bin/systemctl start mysqld.service

四、使用初始密码登录

1

2

[root@localhost ~]# cat /var/log/mysqld.log|grep'A temporary password'

2018-05-18T02:01:17.558742Z 5 [Note] [MY-010454] [Server] A temporary passwordis generatedfor root@localhost: belPU>iuF4*H

最后一行冒号后面的部分belPU>iuF4*H就是初始密码。

五、mysql5.7开始对root密码复杂性要求很高,必须有数字、字母大小写、符号(应该是需要8位以上),这里我么还查show databases;不了。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

[root@localhost ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection idis 10

Server version: 8.0.11

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracleis a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type'help;' or'\h' for help. Type'\c' to clear the current input statement.

mysql> show databases;

ERROR 1820 (HY000): You must reset your passwordusing ALTER USER statement before executingthis statement.

只需要把root密码更改的复杂一些即可。

更改密码方法:

1

2

3

4

5

6

7

8

9

解决办法

1、 修改用户密码

mysql> alter user'root'@'localhost' identifiedby 'youpassword';

或者(下面这个只能修改当前登录的用户密码)

mysql>set password=password("youpassword");

2、刷新权限

mysql> flush privileges;

示例

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

mysql> alter user'root'@'localhost' identifiedby 'qA123,./';

Query OK, 0 rows affected (0.10 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

4 rowsin set (0.01 sec)

重启mysqld服务。

1

[root@localhost ~]# systemctl restart mysqld.service

1

2

3

4

5

6

7

8

常用的命令:

systemctl start mysqld    #启动mysqld

systemctl stop mysqld    #停止mysqld

systemctl restart mysqld    #重启mysqld

systemctl enable mysqld   #设置开机启动

systemctl status mysqld    #查看 MySQL Server 状态

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值