首页 > 编程知识 正文

根据mysql57默认的密码校验规则,mysql5729安装教程

时间:2023-05-04 11:14:10 阅读:250374 作者:3768

转 MySQL5.7初始密码问题 2018年06月29日 10:04:22 Demonson 阅读数:112 更多 <div class="tags-box space"><span class="label">个人分类:</span><a class="tag-link" rel="external nofollow" href="https://blog.csdn.net/demonson/article/category/7450379" target="_blank">MySQL 基础</a><a class="tag-link" rel="external nofollow" href="https://blog.csdn.net/demonson/article/category/7450381" target="_blank">MySQL 架构</a><a class="tag-link" rel="external nofollow" href="https://blog.csdn.net/demonson/article/category/7450388" target="_blank">MySQL 备份恢复</a></div></div><div class="operating"></div></div></div></div><article><div id="article_content" class="article_content clearfix csdn-tracking-statistics" data-pid="blog" data-mod="popu_307" data-dsm="post"> <link rel="stylesheet" rel="external nofollow" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-e2445db1a8.css"><div class="htmledit_views"> <p>  今天在实验室的电脑上安装MySQL5.7的时候,下载了ZIP版,在配置好环境变量之后遇到了不知道初始密码的问题,查找了很多帖子都不行,最后这样解决了问题:</p><p>  1.在MySQL的安装目录下(例如:D:developmysql-5.7.19-winx64)手动新建一个文件,命名为my.ini,再新建一个文件夹data,my.ini文件中,复制内容如下:</p><p>  </p><div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a title="复制代码" target="_blank"><img src="https://common.cnblogs.com/images/copycode.gif" alt="复制代码"></a></span></div><pre><span style="color:#000000;">[mysql] 设置mysql客户端默认字符集

default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306

设置mysql的安装目录

basedir=D:developmysql-5.7.19-winx64

设置mysql数据库的数据的存放目录

datadir=D:developmysql-5.7.19-winx64data

允许最大连接数

max_connections=200

服务端使用的字符集默认为8比特编码的latin1字符集

character-set-server=utf8

创建新表时将使用的默认存储引擎

default-storage-engine=INNODB

2.进入mysql的安装目录下,打开命令提示符(可以Shift+右键->选择命令提示符)输入:mysqld --skip-grant-tables

  回车之后就不要动了,再新打开一个命令提示符窗口,同样进入mysql的安装目录下,

  输入:mysql -u root -p

  密码为空,直接回车

  接着输入以下命令:

  use mysql;

  update user set authentication_string=password(“123456”) where user=“root”;

  flush privileges;

  以上三条命令执行完毕之后,打开命令提示符窗口,

  输入mysql -u root -p,回车(前提是配置好了环境变量,没有配置的可以自行百度)

  输入密码:123456

  成功!

============================================================

安装了mysql5.7之后初始密码不再默认为空

1.查看初始密码:

[root@VM_225_102_centos ~]# grep ‘temporary password’ /var/log/mysqld.log 
2016-07-08T02:25:46.311098Z 1 [Note] A temporary password is generated for root@localhost: MtPqF0/oN5zo

即初始密码为 MtPqF0/oN5zo    (密码是随机产生的,每台机器产生的都不一样哦)

或者

另外一种方法查看默认密码:

[root@localhost src]# cat /root/.mysql_secret

# The random password set for the root userat Fri Jan 10 20:00:34 2014 (local time): aJqZsA2m

这里的aJqZsA2m就是生成的root随机密码啦

2.登录及修改密码:

[root@VM_225_102_centos ~]# mysql -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.7.11


Copyright © 2000, 2016, Oracle and/or its affiliates. All rights reserved.


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> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.


登录之后 第一步必须先修改密码,否则其他操作都执行不了。


修改密码的方法:


mysql> alter user root@localhost identified by ‘tyzZ001!’;
Query OK, 0 rows affected (0.00 sec)

新修改的密码中 必须包含 大小写字母数字及符号

发现有些不支持上述方法 另提供一种思路 

点击查看:MySQL忘记root密码解决方案



Vue新一代状态管理工具Pinia的具体使用如何编写用于日期格式验证的正则表达式?北京idc托管价格

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。