mysql8重新安装
  DF5J4hb0hcmT 2023年12月11日 30 0

之前文章记录了mysql安装过程,由于忘记root用户密码,重新安装windows版本mysql。

版本:mysql-8.2.0-winx64.zip

win11

停止服务

以管理员身份打开命令行

PS C:\Users\admin> net stop mysql8
mysql8 服务正在停止..
mysql8 服务已成功停止。

删除服务

以管理员身份打开命令行

sc delete mysql8

配置环境变量

由于重装后的mysql文件夹和之前相同,此步略过。

恢复之前配置文件

由于之前端口号改成了3308,下文连接将使用此端口。

初始化

PS D:\1_dev\mysql-8.2.0-winx64\bin> .\mysqld --install mysql8
Service successfully installed.
PS D:\1_dev\mysql-8.2.0-winx64\bin> net start mysql8
mysql8 服务正在启动 .
mysql8 服务无法启动。

服务没有报告任何错误。

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

PS D:\1_dev\mysql-8.2.0-winx64\bin> mysqld --initialize --console
2023-12-11T06:35:06.291608Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2023-12-11T06:35:06.296715Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2023-12-11T06:35:06.296732Z 0 [System] [MY-013169] [Server] D:\1_dev\mysql-8.2.0-winx64\bin\mysqld.exe (mysqld 8.2.0) initializing of server in progress as process 21180
2023-12-11T06:35:06.315413Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-12-11T06:35:06.852171Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-12-11T06:35:08.531965Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: umSwEoD!I7i5
2023-12-11T06:35:08.746996Z 6 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
2023-12-11T06:35:11.116206Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
PS D:\1_dev\mysql-8.2.0-winx64\bin> mysql -uroot -p -P3308
Enter password: ************
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost:3308' (10061)
PS D:\1_dev\mysql-8.2.0-winx64\bin> net start mysql8
mysql8 服务正在启动 .
mysql8 服务已经启动成功。

修改root用户密码

修改成新的root密码,root用户默认本地连接。

PS D:\1_dev\mysql-8.2.0-winx64\bin> mysql -uroot -p -P3308
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.2.0

Copyright (c) 2000, 2023, 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>alter user 'root'@'localhost' identified by 'your_password';
Query OK, 0 rows affected (0.01 sec)

恢复之前数据库

停止mysql服务。

PS D:\1_dev\mysql-8.2.0-winx64\bin> net stop mysql8;
mysql8 服务正在停止.
mysql8 服务已成功停止。

备份mysql-8.2.0-winx64\Data目录,从原来文件夹复制Data过来。

启动mysql服务(紧张...)

PS D:\1_dev\mysql-8.2.0-winx64\bin> net start mysql8;
mysql8 服务正在启动 .
mysql8 服务已经启动成功。

之前数据库都在

mysql8重新安装_MySQL

创建其他用户

mysql> CREATE USER 'tsoc'@'%' IDENTIFIED BY 'your_password';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'tsoc'@'%';
Query OK, 0 rows affected (0.01 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)




【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年12月11日 0

暂无评论

推荐阅读
  DF5J4hb0hcmT   2023年12月11日   31   0   0 mysql
  DF5J4hb0hcmT   2023年11月02日   50   0   0 mysqldocker
  DF5J4hb0hcmT   2023年11月02日   37   0   0 mysqldocker
DF5J4hb0hcmT