阿里云centos7修改mysql密码_CentOS7安装MySQL5.7密码查看与修改 - MySQL中文参考手册...

本文介绍了如何在CentOS7上安装MySQL5.7,包括卸载旧版本、下载安装包、启动服务以及查看初始密码。接着详细讲解了如何修改MySQL的初始密码,强调了现在MySQL对于密码强度的要求,并提供了设置新密码的方法。此外,还提到了如何忘记密码时的解决办法以及调整密码策略。最后,文章涵盖了创建新用户和授权的步骤。
摘要由CSDN通过智能技术生成

CentOS7 安装 Mysql 5.7密码查看与修改

软件版本CentOS release 6.9 (Final)mysql Client Ver 14.14 Distrib 5.7.18, for Linux (x86_64) using  EditLine wrappermysql Server 5.7.18

检测是否安装MySQLServer

检测下系统有没有自带的mysql:yum list installed | grep mysql

如果已经有的话执行命令 yum -y remove mysql-libs.x86_64 卸载已经安装的 MySQL 。

安装

使用 rpm 包进行mysql服务器的安装,具体下载地址在:https://dev.mysql.com/downloads/mysql/5.7.html#downloadswget http://repo.mysql.com/yum/mysql-5.7-community/el/6/x86_64/mysql-community-server-5.7.18-1.el6.x86_64.rpmrpm -ivh mysql-community-server-5.7.18-1.el6.x86_64.rpm

启动service mysqld start

查看密码

安装完成之后会自动在 /var/log/mysqld.log 中生成连接的密码, 使用 grep "temporary password" /var/log/mysqld.log 命令查看生成的密码。

初次登录MySQL客户端必须重新设置密码才能进行数据的操作,如下:[root@localhost src]# mysql -uroot -pEnter password:Welcome to the MySQL monitor.  Commands end with ; or /g.Your MySQL connection id is 7Server version: 5.7.18Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.mysql> show databases;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

密码设置

不过需要注意的是现在MySQL已经强制要求强密码,已经不能再用弱密码比如“123456”了。如果你设置的密码过于简单,会提示错误:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

set password 命令SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

mysqladmin 命令mysqladmin -u root password "newpass" # 如果root没有设置密码使用这种方式mysqladmin -u root password oldpass "newpass" # 如果root设置了密码使用这种方式

使用 update 语句UPDATE user SET authentication_string = PASSWORD('newpass') WHERE user = 'root';

忘记密码mysqld_safe --skip-grant-tables&mysql -u root mysqlmysql> UPDATE user SET authentication_string=PASSWORD("new password") WHERE user='root';mysql> FLUSH PRIVILEGES;

密码复杂度的修改mysql> show variables like "validate_password%";+--------------------------------------+--------+| Variable_name                        | Value  |+--------------------------------------+--------+| validate_password_check_user_name    | OFF    || validate_password_dictionary_file    |        || validate_password_length             | 8      | # 必须8个字符以上| validate_password_mixed_case_count   | 1      || validate_password_number_count       | 1      || validate_password_policy             | MEDIUM | # 具体看下面的配置| validate_password_special_char_count | 1      |+--------------------------------------+--------+7 rows in set (0.01 sec)mysql> SET GLOBAL  validate_password_policy='LOW';Query OK, 0 rows affected (0.00 sec)mysql> SET GLOBAL validate_password_length = 6;Query OK, 0 rows affected (0.00 sec)LOW政策只测试密码长度。 密码必须至少有8个字符长。

MEDIUM政策的条件 密码必须包含至少1数字字符,1 大写和小写字符,和1特别 (nonalphanumeric)字符。

STRONG政策的情况 密码子字符串长度为4的或更长时间不能匹配 单词在字典文件中,如果一个人被指定。

再进行密码的修改试试。

创建用户并授权CREATE USER 'test'@'%' IDENTIFIED BY 'password';GRANT ALL ON test.* TO 'test'@'%' WITH GRANT OPTION;

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值