yum安装mysql扩展_使用yum安装mysql

之前在Linux中yum和apt-get中列出了linux软件管理的一些常用操作,这里实际以mysql为例进行一次安装演示。

配置mysql扩展源1rpm -ivh http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm

yum安装mysql1yum install mysql-community-server -y

查看mysql状态,启动,开机自启设置

查看mysql状态1

2

3

4

5

6[root@localhost ~]# systemctl status mysqld

● mysqld.service - MySQL Server

Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)

Active: inactive (dead)

Docs: man:mysqld(8)

http://dev.mysql.com/doc/refman/en/using-systemd.html

启动mysql,并设置开机自启1

2[root@localhost ~]# systemctl start mysqld

[root@localhost ~]# systemctl enable mysqld

再次查看状态可以看到mysql已经启动起来了1

2

3

4

5

6

7

8

9

10

11

12[root@localhost ~]# systemctl status mysqld

● mysqld.service - MySQL Server

Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)

Active: active (running) since 三 2020-08-12 13:08:40 CST; 22s ago

Docs: man:mysqld(8)

http://dev.mysql.com/doc/refman/en/using-systemd.html

Main PID: 30522 (mysqld)

CGroup: /system.slice/mysqld.service

└─30522 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

8月 12 13:08:34 localhost.localdomain systemd[1]: Starting MySQL Server...

8月 12 13:08:40 localhost.localdomain systemd[1]: Started MySQL Server.

使用mysql初始密码登录

mysql的初始密码在哪儿呢?1

2

3

4

5

6

7

8

9

10[root@localhost ~]# cat /var/log/mysqld.log

2020-08-12T05:08:34.775425Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see doc

umentation for more details).2020-08-12T05:08:35.467104Z 0 [Warning] InnoDB: New log files created, LSN=45790

2020-08-12T05:08:35.571012Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2020-08-12T05:08:35.636312Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating

a new UUID: dffd9de5-dc59-11ea-9b06-000c298217df.2020-08-12T05:08:35.639692Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2020-08-12T05:08:36.708627Z 0 [Warning] CA certificate ca.pem is self signed.

2020-08-12T05:08:36.737506Z 1 [Note] A temporary password is generated for root@localhost: lug76/d98m!F

2020-08-12T05:08:39.278229Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see doc

umentation for more details).

查看该日志文件,可以看到密码为:lug76/d98m!F

或者使用命令行查看,一样的密码1

2[root@localhost ~]# echo $(awk '/temporary password/{print $NF}' /var/log/mysqld.log)

lug76/d98m!F

使用该初始密码进行登录1mysql -uroot -p$(awk '/temporary password/{print $NF}' /var/log/mysqld.log)

修改数据库密码

我们尝试直接修改密码:1

2set password for root@localhost = password('123456');

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

直接报错,提示不符合密码策略要求。

数据库默认密码规则必须携带大小写字母、特殊符号,字符长度大于8否则会报错。

因此设定较为简单的密码时需要首先修改set global validate_password_policy和_length参数值。1

2

3

4

5

6set global validate_password_policy=0;

Query OK, 0 rows affected (0.00 sec)

set global validate_password_length=1;

Query OK, 0 rows affected (0.00 sec)

set password for root@localhost = password('123456');

Query OK, 0 rows affected, 1 warning (0.00 sec)

登录测试1

2

3

4

5

6

7

8

9

10

11[root@localhost ~]# mysql -uroot -p123456

show databases;

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

| Database |

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

| information_schema |

| mysql |

| performance_schema |

| sys |

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

4 rows in set (0.00 sec)

至此,mysql已经成功安装在我们linux环境中

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值