MySQL安装及密码修改
序言:
MySQL是世界上最受欢迎的数据库管理系统之一。无论是在小型开发项目上还是在大型网站上面,它都是稳定的、可靠、快速、可信的,可以足够胜任任何数据存储需求。
PS:嘿嘿,其实本人学习MySQL主要原因是想要学习SQL注入,但是在学习的过程中也遇见了一些问题,把问题及问题的解决方案分享出来希望能够帮助到那些遇到相同问题的人,若有不足,请各位大佬多多斧正。
参考资料:
Mysql - flush privileges 命令:
https://blog.youkuaiyun.com/zhangzheng0413/article/details/7243265
正文:
操作系统:Microsoft Windows 10 21H1
MySQL版本:MySQL Community Server 8.0.26
Java环境:
Java™ SE Runtime Environment (build 15.0.1+9-18)
Java HotSpot™ 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)
安装过程:
Java环境搭建:
看一看龙龙之前写过的吧,不过多赘述了呦~~(主要是比较懒,嘿嘿):
https://blog.youkuaiyun.com/weixin_46056304/article/details/108987409?spm=1001.2014.3001.5502
MySQL下载:
网址:
https://dev.mysql.com/downloads/mysql/
一、安装:
C:\Windows\system32>d: #切换到D盘
D:\>cd MySQL\SQL\bin #切换到MySQL文件夹
D:\MySQL\SQL\bin>mysqld --initialize --console #初始化MySQL
2021-07-26T11:51:37.672431Z 0 [System] [MY-013169] [Server] D:\MySQL\SQL\bin\mysqld.exe (mysqld 8.0.26) initializing of server in progress as process 6024
2021-07-26T11:51:37.679627Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2021-07-26T11:51:37.695772Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-07-26T11:51:38.187110Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-07-26T11:51:39.493894Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2021-07-26T11:51:39.494483Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2021-07-26T11:51:39.594086Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: havj1rP#5Xct #初始密码
D:\MySQL\SQL\bin>mysqld install #安装MySQL
The service already exists!
The current server installed: D:\MySQL\SQL\bin\mysqld MySQL
D:\MySQL\SQL\bin>net start mysql #启动服务
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
D:\MySQL\SQL\bin>mysql -u root -p #登录
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26
Copyright (c) 2000, 2021, 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>
二.修改密码:
C:\Users\ASUS\Desktop>mysql -u root -p #使用初始密码登录
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 8.0.26 MySQL Community Server - GPL
Copyright (c) 2000, 2021, 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> use mysql;
Database changed
mysql> update user set authentication_string='' where user='root'; #清空authentication_string
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> alter user 'root'@'localhost' identified by 'newpassword'; #设置新的密码,newpassword就是新的密码
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges; #刷新MySQL的系统权限相关表,此过程是必要过程, 否则会出现拒绝访问
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
三.修改密码(忘记密码的操作):
1.先以管理员身份打开一个DOS窗口:
C:\Users\ASUS\Desktop> stop mysql #停止MySQL服务
C:\Users\ASUS\Desktop> --shared-memory --skip-grant-tables #锁定命令提示符窗口
2.再打开另一个窗口,修改密码:
C:\Users\ASUS\Desktop> mysql -uroot -p #无需密码直接回车登录
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 8.0.26 MySQL Community Server - GPL
Copyright (c) 2000, 2021, 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> use mysql;
Database changed
mysql> update user set authentication_string='' where user='root'; #清空authentication_string
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> alter user 'root'@'localhost' identified by 'newpassword'; #设置新的密码,newpassword就是新的密码
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges; #刷新MySQL的系统权限相关表,此过程是必要过程, 否则会出现拒绝访问
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
175

被折叠的 条评论
为什么被折叠?



