您的位置:首页 > 房产 > 建筑 > mysql--安装跳过验证修改密码安全加固

mysql--安装跳过验证修改密码安全加固

2024/10/7 4:36:53 来源:https://blog.csdn.net/m0_65342309/article/details/139768010  浏览:    关键词:mysql--安装跳过验证修改密码安全加固

安装mysql

配置mysql的yum源

[root@VM-0-14-rockylinux ~]# tee /etc/yum.repos.d/mysql.repo << EOF
> [MYSQL]
> name=mysql
> baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64
> gpgcheck=0
> EOF

yum安装mysql

yum -y install mysql-community-server

设置开机自启动

systemctl enable --now mysqld

 访问mysql

 跳过密码验证(1045错误处理)

vim /etc/my.cnf

[mysqld]
skip-grant-tables

重启服务

systemctl restart mysqld

 进入

修改密码

方法一

mysql> alter user root@'localhost' identified by '000000';

 方法二

mysqladmin -uroot -p 初始密码 password 修改密码

 初始化脚本提高安全性

[root@VM-0-14-rockylinux ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.44 MySQL Community Server (GPL)Copyright (c) 2000, 2023, 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> stastus-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'stastus' at line 1
mysql> status;
--------------
mysql  Ver 14.14 Distrib 5.7.44, for Linux (x86_64) using  EditLine wrapperConnection id:          2
Current database:
Current user:           root@
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.7.44 MySQL Community Server (GPL)
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 29 secThreads: 1  Questions: 6  Slow queries: 0  Opens: 97  Flush tables: 1  Open tables: 92  Queries per second avg: 0.206
--------------mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)mysql> select user,host from mysql.user;
+---------------+-----------+
| user          | host      |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys     | localhost |
| root          | localhost |
+---------------+-----------+
3 rows in set (0.00 sec)

 都选y

版权声明:

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

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