Linux下MySQL的安装部署

网络仓库安装

安装官方软件仓库:https://repo.mysql.com//mysql80-community-release-el9-5.noarch.rpm

[root@client ~]# yum install https://repo.mysql.com//mysql80-community-release-el9-5.noarch.rpm  -y   //安装MySQL

[root@localhost yum.repos.d]# ll               //查看/etc/yum.repos.d 底下文件

total 36

-rw-r--r--. 1 root root 13319 Oct 24 22:44 mysql80-community-release-el9-

5.noarch.rpm

-rw-r--r--. 1 root root 2129 Oct 24 21:13 mysql-community-debuginfo.repo

-rw-r--r--. 1 root root 1910 Oct 24 21:13 mysql-community.repo

-rw-r--r--. 1 root root 1989 Oct 24 21:13 mysql-community-source.repo

过滤MySQL包 

[root@localhost ~]# dnf repolist enabled | grep mysql      

mysql-connectors-community           MySQL Connectors Community

mysql-tools-community                     MySQL Tools Community

mysql80-community                           MySQL 8.0 Community Server

安装MySQL包

[root@localhost ~]# dnf install mysql* -y    

Updating Subscription Management repositories.

Unable to read consumer identity

This system is not registered with an entitlement server. You can use

subscription-manager to register

安装的完成后重新启动MySQL服务

[root@node4 mysql]# systemctl start mysqld.service          #启动服务

[root@node4 mysql]# systemctl enable mysqld.service --now  #开机自启

[root@localhost ~]# systemctl start mysqld     #重启服务

MySQL的登入 

[root@localhost ~]# mysql -uroot -p          //第一次需要使用本地提供的密码

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:

NO)

[root@localhost ~]# grep password  /var/log/mysqld.log     //查找本地密码

2024-01-03T08:38:42.943965Z 6 [Note] [MY-010454] [Server] A temporary password is

generated for root@localhost: t5BLwdq*orTp

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

Enter password:

mysgl> ALTER USER 'root''localhost' IDENTIFIED WITH mysgl native password By 123456X=y';         //此处必须修改密码  不然无法进行下一步操作

修改MySQL的密码策略,使密码更加简单 

mysql> show variables like 'validate password%';       //显示密码策略

Linux下MySQL的安装部署_第1张图片

更改密码策略

mysql> set global validate password_policy=LOW;

mysql> set global validate_password_length=4;

Ouerv ok. rows affected (. sec)

mysql> alter user root@localhost identified by 'mysql';    #再次修改密码

或者更改/etc/my.cnf的配置文件

[root@node3 builer]# vim /etc/my.cnf

skip-grant-tables                  //加上这一行(跳过授权表) 

[root@node3 builer7# systemctl start mysqld.service   //重启服务

[root@node3 builer]# mysgl -uroot -p       #可以无密码登录

你可能感兴趣的:(linux,mysql,adb)