linux系统安装mysql服务

1.下载安装包

https://downloads.mysql.com/archives/community/
mysql下载地址
在这里插入图片描述

2.下载压缩文件解压安装

tar -xvf mysql-8.0.36-1.el7.x86_64.rpm-bundle.tar

解压文件如下:因为文件安装有先后顺序,按下面顺序安装
在这里插入图片描述
yum -vih rpm包
在这里插入图片描述

3. 安装完启动服务

[root@hdss7-6 package]# systemctl start mysqld

4.查看安装密码

[root@hdss7-6 package]# tail -f /var/log/mysqld.log
2024-08-15T08:49:32.024260Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-08-15T08:49:32.431493Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-08-15T08:49:33.673562Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: KIw;>o1cnM+c
2024-08-15T08:49:36.950141Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.36) starting as process 20544
2024-08-15T08:49:36.977304Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-08-15T08:49:37.184250Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-08-15T08:49:37.823413Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2024-08-15T08:49:37.823507Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2024-08-15T08:49:37.858411Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2024-08-15T08:49:37.858733Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.36'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server - GPL.

查看密码

[root@hdss7-6 package]# grep 'temporary password' /var/log/mysqld.log

2024-08-15T08:49:33.673562Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: KIw;>o1cnM+c

5.使用上述密码登录

[root@hdss7-6 mysql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.36

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is 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>

6.修改密码

mysql> alter user 'root'@'localhost' identified by '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql>

密码的规则官网要求

政策 执行的测试
0或LOW 长度
1或MEDIUM 长度;数字、小写/大写和特殊字符
2或STRONG 长度;数字、小写/大写和特殊字符;字典 文件

先修改原始密码,才可以执行设置命令;

mysql> alter user user() identified by 'hahhah**&&1';
Query OK, 0 rows affected (0.06 sec)

设置密码规则

mysql> set global validate_password.policy = 0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password.length = 4;
Query OK, 0 rows affected (0.01 sec)

修改密码为123456成功

mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

7.创建一个root可以在任意主机远程连接数据库

mysql> create user 'root'@'%' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.03 sec)

配置权限

grant all on *.* to 'root'@'%';

8.远程登录成功

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值