• mysql运行报错:


    Install/Remove of the Service Denied!
    
    • 1

    解决办法: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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    只需要把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。
    
    无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动。
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

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

    在这里插入图片描述
    如果改不了,管理员运行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>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60

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

    修改密码

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

    注意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>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25

    以上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,新建连接
    在这里插入图片描述

  • 相关阅读:
    【C++智能指针】(面试)使用my_weak_ptr解决循环引用问题
    解决SpringCloud的Gateway网关无法访问服务的静态资源
    Vue2基础用法及案例
    tushare美股行情怎么获取?
    Maven插件mybatis-generator,如何让生成的PO类的field上有对应表字段的注释
    MATLAB R2022b遇到“License Manager Error -8”怎么解决
    CommonsCollection4反序列化链学习
    牛客刷题总结——Python入门:输入输出、字符串、类型转换
    解决docker开启MySQL的binlog无法成功。docker内部报错:mysql: [ERROR] unknown variable
    数组(持续更新后续)
  • 原文地址:https://blog.csdn.net/m0_47010003/article/details/127939562