mysql运行报错:

Install/Remove of the Service Denied!

解决办法:Install/Remove of the Service Denied解决办法
在这里插入图片描述

在这里插入图片描述
上面报错看这篇:MySQL本地连接报错:ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost‘ (10061)

在这里插入图片描述
上面报错看这篇:windows按照mysql报错mysqld: Can‘t create directory ‘xxx\data\‘ (Errcode: 2 - No such file or directory)
在这里插入图片描述

D:\software\MySQL\mysql\bin>mysqld --initialize-insecure
2022-11-19T11:20:28.713208Z 0 [Warning] option 'read_buffer_size': unsigned value 0 adjusted to 8192
2022-11-19T11:20:28.713260Z 0 [Warning] option 'read_rnd_buffer_size': unsigned value 0 adjusted to 1
2022-11-19T11:20:28.713288Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-11-19T11:20:28.713302Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2022-11-19T11:20:28.716502Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2022-11-19T11:20:28.716963Z 0 [ERROR] Aborting

只需要把data文件夹删除就好
在这里插入图片描述
再次初始化成功mysqld --initialize-insecure
但是输入net start mysql还是报错
发生系统错误 2。

系统找不到指定的文件。
在这里插入图片描述

D:\software\MySQL\mysql\bin>mysqld --initialize-insecure

D:\software\MySQL\mysql\bin>net start mysql
发生系统错误 2。

系统找不到指定的文件。


D:\software\MySQL\mysql\bin>mysqld --remove
Service successfully removed.

D:\software\MySQL\mysql\bin>mysqld --install
The service already exists!
The current server installed: D:\软件\MySQL\mysql\bin\mysqld.exe MySQL

D:\software\MySQL\mysql\bin>net start mysql
发生系统错误 1058。

无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动。

解决方式:
在这里插入图片描述

在这里插入图片描述
如果改不了,管理员运行cmd,输入net start mysql
在这里插入图片描述

在这里插入图片描述
如下步骤,其中执行mysqld --initialize --console前先把data目录全删除了,我第一遍就是没有删除报错了,执行成功后,注意密码,在最后一行结尾+hfkwHTM<5(A,随机密码,待会mysql -uroot -p登录输入的密码就是这个
:2022-11-20T04:52:30.400686Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: +hfkwHTM<5(A

icrosoft Windows [版本 10.0.22000.1219]
(c) Microsoft Corporation。保留所有权利。

C:\WINDOWS\system32>net start mysql
mysql 服务正在启动 .
mysql 服务已经启动成功。


C:\WINDOWS\system32>mysql -uroot -p
Enter password: ******
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost:3306' (10061)

C:\WINDOWS\system32>sc delete mysql
[SC] DeleteService 成功

C:\WINDOWS\system32>mysqld --install
Service successfully installed.

C:\WINDOWS\system32>mysqld --initialize --console
2022-11-20T04:51:42.879195Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-11-20T04:51:42.879211Z 0 [System] [MY-013169] [Server] D:\mysql-8.0.31-winx64\mysql-8.0.31-winx64\bin\mysqld.exe (mysqld 8.0.31) initializing of server in progress as process 9468
2022-11-20T04:51:42.879296Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file 'D:\mysql-8.0.26-winx64\mysql-8.0.26-winx64\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2022-11-20T04:51:42.880595Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2022-11-20T04:51:42.887947Z 0 [ERROR] [MY-013236] [Server] The designated data directory D:\\mysql-8.0.31-winx64\mysql-8.0.31-winx64\data\ is unusable. You can remove all files that the server added to it.
2022-11-20T04:51:42.890280Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-11-20T04:51:42.890477Z 0 [System] [MY-010910] [Server] D:\mysql-8.0.31-winx64\mysql-8.0.31-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.31)  MySQL Community Server - GPL.

C:\WINDOWS\system32>mysqld --initialize --console
2022-11-20T04:52:29.062287Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-11-20T04:52:29.062303Z 0 [System] [MY-013169] [Server] D:\mysql-8.0.31-winx64\mysql-8.0.31-winx64\bin\mysqld.exe (mysqld 8.0.31) initializing of server in progress as process 10272
2022-11-20T04:52:29.062379Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file 'D:\mysql-8.0.26-winx64\mysql-8.0.26-winx64\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2022-11-20T04:52:29.080130Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-11-20T04:52:29.469558Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-11-20T04:52:30.165490Z 0 [Warning] [MY-013829] [Server] Missing data directory for ICU regular expressions: D:\mysql-8.0.26-winx64\mysql-8.0.26-winx64\lib\private\.
2022-11-20T04:52:30.400686Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: +hfkwHTM<5(A

C:\WINDOWS\system32>mysql -uroot -p
Enter password: ************
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost:3306' (10061)

C:\WINDOWS\system32>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。


C:\WINDOWS\system32>mysql -uroot -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.31

Copyright (c) 2000, 2022, 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>

最后输入netstat -ano ,查看3306端口号
在这里插入图片描述
在这里插入图片描述

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY'123456';

注意BY后面没有空格直接跟’123456’
在这里插入图片描述
修改成功后,show databases; 查看数据库:
在这里插入图片描述

远程连接

mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by '123456' with grant option' at line 1
mysql> create user 'root'@'%' identified by '123456';
ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'%'
mysql> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| %         | root             |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
+-----------+------------------+
4 rows in set (0.00 sec)

mysql> create user 'root1'@'%' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> grant all privileges on *.* to 'root1'@'%' with grant option;
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)

mysql>

以上root已经存在了,所以创建一个root1
MySQL赋权报错:’the right syntax to use near ‘identified by ‘123456‘ with grant option‘:MySQL赋权报错:’the right syntax to use near ‘identified by ‘password‘ with grant option

打开SQLyog,新建连接
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

素心如月桠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值