您的位置:首页 > 文旅 > 旅游 > linux系统安装mysql服务

linux系统安装mysql服务

2024/12/26 17:48:08 来源:https://blog.csdn.net/qiao2458/article/details/141226565  浏览:    关键词:linux系统安装mysql服务

linux系统安装mysql服务

    • 1.下载安装包
    • 2.下载压缩文件解压安装
    • 3. 安装完启动服务
    • 4.查看安装密码
    • 5.使用上述密码登录
    • 6.修改密码
    • 7.创建一个root可以在任意主机远程连接数据库
    • 8.远程登录成功

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.log2024-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.36Copyright (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.远程登录成功

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com