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

MySql服务重启

首先,要确保cmd.exe是以管理员身份运行的!!!

C:Usersadmin>cd D:msqin
C:Usersadmin> d:
D:msqin>mysqld -remove
The service doesn't exist!
D:msqin>mysqld -install
Service successfully installed.
D:msqin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

D:msqin>
****************************************************************************
######################################################################################################
  5.1及后续版本:
C:Usersadmin>cd D:msqin
C:Usersadmin> d:
D:MySQLin>mysqld.exe -install
Service successfully installed.

D:MySQLin>net start mysql

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

MySQL 服务正在启动 .
MySQL 服务无法启动。

服务没有报告任何错误。

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

D:MySQLin>mysqld --initialize

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

2019-06-28T03:50:55.493433Z 0 [System] [MY-013169] [Server] F:SOFT_DATAmySqlmysql-8.0.12-winx64mysql-8.0.12-winx64inmysqld.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_DATAmySqlmysql-8.0.12-winx64mysql-8.0.12-winx64inmysqld.exe: Shutdown complete (mysqld 8.0.12) MySQL Community Server - GPL.

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

D:MySQLin>net start mysql

MySQL 服务正在启动 ...
MySQL 服务已经启动成功。

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

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

5.0版本:
D:MySQLin>mysqld-nt.exe -install
Service successfully installed.

D:MySQLin>net start mysql

MySQL 服务已经启动成功。 

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

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

用记事本打开err文件

可以看到临时密码:<a5F34))PqMb

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

D:softDatamysqlmysql-8.0.12-winx64in>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 <item>', where <item> 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. 1

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

    如何修改mysql密码
  2. 2

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

    如何修改mysql密码
    END

方法2

 
  1. 1

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

    如何修改mysql密码
    END

方法3-忘记密码时

 
  1.  

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

    如何修改mysql密码
  2.  

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

    如何修改mysql密码
  3.  

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

    如何修改mysql密码
    如何修改mysql密码
  4.  

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

    如何修改mysql密码
  5. 5

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

    如何修改mysql密码
  6.  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)

原文地址:https://www.cnblogs.com/hanwuxing/p/8431636.html