mysql 服务器初始密码_MySql服务器重启 || 修改mysql原始密码

C:\Users\admin>cd D:\msq\bin

C:\Users\admin> d:

D:\MySQL\bin>mysqld.exe -install

Service successfully installed.

D:\MySQL\bin>net start mysql

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

MySQL 服务正在启动 .

MySQL 服务无法启动。

服务没有报告任何错误。

请键入 NET HELPMSG 3534 以获得更多的帮助。

D:\MySQL\bin>mysqld --initialize

(注意:如果此命令键入后,系统提示如下:

2019-06-28T03:50:55.493433Z 0 [System] [MY-013169] [Server] F:\SOFT_DATA\mySql\mysql-8.0.12-winx64\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) initializing of server in progress as process 7172

2019-06-28T03:50:55.495802Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.

2019-06-28T03:50:55.502761Z 0 [ERROR] [MY-010119] [Server] Aborting

2019-06-28T03:50:55.503959Z 0 [System] [MY-010910] [Server] F:\SOFT_DATA\mySql\mysql-8.0.12-winx64\mysql-8.0.12-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.12) MySQL Community Server - GPL.

则需要删除安装目录下的data文件夹里的所有数据,再重试)

D:\MySQL\bin>net start mysql

MySQL 服务正在启动 ...

MySQL 服务已经启动成功。

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

###############################################################################################

5.0版本:

D:\MySQL\bin>mysqld-nt.exe -install

Service successfully installed.

D:\MySQL\bin>net start mysql

MySQL 服务已经启动成功。

¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥修改密码¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥

1)在mysql安装目录生成的data文件下,查找xxx.err的文件如图:

a355fd1747c1b54cf022d22c967d70cb.png

用记事本打开err文件

b134af89ef6a0c2c86ba3325a9b8c8b9.png

可以看到临时密码:

使用cmd命令行工具,用临时密码登录,进行修改密码

D:\softData\mysql\mysql-8.0.12-winx64\bin>mysql -u root -p

Enter password: ************(.err文件中的密码)

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 20

Server version: 8.0.12

Copyright (c) 2000, 2018, 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>alter user 'root'@'localhost' identified by 'root';

Query OK, 0 rows affected (0.17 sec)

mysql> flush privileges;         ###############################(密码已经重置成功了!!!)

Query OK, 0 rows affected (0.06 sec)

mysql> help contents

You asked for help about help category: "Contents"

For more information, type 'help ', where is one of the following

categories:

Account Management

Administration

Components

Compound Statements

Data Definition

Data Manipulation

Data Types

Functions

Functions and Modifiers for Use with GROUP BY

Geographic Features

Help Metadata

Language Structure

Plugins

Storage Engines

Table Maintenance

Transactions

User-Defined Functions

Utility

mysql>

Mysql 8.0 1251 client does no support authentic的错误解决方式

1.查看用户信息

select host,user,plugin,authentication_string from mysql.user;

2.更新user为root,host为localhost 的密码为mysql

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

如何修改mysql密码

使用mysql中我们有时可能需要修改密码防止数据库被黑掉,下文教你如何修改密码

方法1

1

首先在cmd中输入mysql -uroot -p,之后输入旧的密码打开mysql命令行

5edb25a277c5cdd150e8a8a1c5f301c7.png

2

之后输入set password for 用户名@localhost = password('新密码'); 来设置新的密码。

9541cdafaa30fbceb397fde856ce732b.png

END

方法2

1

打开cmd直接输入命令mysqladmin -u用户名 -p旧密码 password 新密码

bbfb9ed4dedabb1a502cb9f547f444f4.png

END

方法3-忘记密码时

对于新版本按照这个步骤,首先使用net stop mysql(服务名称)关闭mysql服务

7508199ac74ac51201a7e2d04f76a003.png

服务名称可以通过电脑管理中查看到,首先打开我的计算机管理页面,点击服务与应用程序

4d5db404bb137de59cbe9db4e9dbda61.png

然后点击服务,在服务列表可以找到mysql服务名称

9a3f210c064049a5c486a839941f45bc.png

b8fbb8947fe1ecbdd87c42e4154d30b4.png

停止mysql服务后,输入mysqld --console --skip-grant-tables --shared-memory,旧版使用mysqld –skip-grant-tables,之后出现如下图提示

7d0d3317752561b3893b2009c460647d.png

5

再次启动一个cmd窗口,输入mysql即可进入mysql命令行页面,按照方法1设置密码即可

2d98e1e01428e6353eeb6ba00091fd94.png

The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement  (权限不足时)

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

=======================此时完结===================================

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值