以下是cmd的操作 (重启服务,修改my.ini 文章下面有my.ini配置) 当修改密码为123456是sqlyog连接成功 修改为root时连接报老错误,又修改为123456 在修改为root就连接正常了
Microsoft Windows [版本 10.0.18363.1139]
(c) 2019 Microsoft Corporation。保留所有权利。
C:\Program Files\MySQL\MySQL Server 8.0>mysql -u -root -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
C:\Program Files\MySQL\MySQL Server 8.0>mysql -u -root -p
Enter password:
ERROR 1045 (28000): Access denied for user '-root'@'localhost' (using password: NO)
C:\Program Files\MySQL\MySQL Server 8.0>net stop mysql
没有启动 mysql 服务。
请键入 NET HELPMSG 3521 以获得更多的帮助。
C:\Program Files\MySQL\MySQL Server 8.0>start stop mysql
系统找不到文件 stop。
C:\Program Files\MySQL\MySQL Server 8.0>start stop mysql
系统找不到文件 stop。
C:\Program Files\MySQL\MySQL Server 8.0>net start mysql
发生系统错误 1058。
无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动。
C:\Program Files\MySQL\MySQL Server 8.0>mysql -u -root -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
C:\Program Files\MySQL\MySQL Server 8.0>mysql -uroot -p
mysql: [ERROR] Unknown suffix 'X' used for variable 'port' (value 'X').
mysql: [ERROR] mysql: Error while setting value 'X' to 'port'.
C:\Program Files\MySQL\MySQL Server 8.0>mysql -uroot -p
mysql: [ERROR] Unknown suffix 'X' used for variable 'port' (value 'X').
mysql: [ERROR] mysql: Error while setting value 'X' to 'port'.
C:\Program Files\MySQL\MySQL Server 8.0>mysql -uroot -p
mysql: [ERROR] Unknown suffix 'X' used for variable 'port' (value 'X').
mysql: [ERROR] mysql: Error while setting value 'X' to 'port'.
C:\Program Files\MySQL\MySQL Server 8.0>mysql -u -root -p
mysql: [ERROR] Unknown suffix 'X' used for variable 'port' (value 'X').
mysql: [ERROR] mysql: Error while setting value 'X' to 'port'.
C:\Program Files\MySQL\MySQL Server 8.0>mysql -u -root -p
Enter password:
ERROR 1045 (28000): Access denied for user '-root'@'localhost' (using password: NO)
C:\Program Files\MySQL\MySQL Server 8.0>mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
C:\Program Files\MySQL\MySQL Server 8.0>mysql -uroot -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
C:\Program Files\MySQL\MySQL Server 8.0>mysql -u -root -p
Enter password:
ERROR 1045 (28000): Access denied for user '-root'@'localhost' (using password: NO)
C:\Program Files\MySQL\MySQL Server 8.0>net stop mysql
没有启动 mysql 服务。
请键入 NET HELPMSG 3521 以获得更多的帮助。
C:\Program Files\MySQL\MySQL Server 8.0>net start mysql
发生系统错误 1058。
无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动。
C:\Program Files\MySQL\MySQL Server 8.0>mysql -u -root -p
Enter password:
ERROR 1045 (28000): Access denied for user '-root'@'localhost' (using password: NO)
C:\Program Files\MySQL\MySQL Server 8.0>mysql -u -root -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
C:\Program Files\MySQL\MySQL Server 8.0>mysql -uroot -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
C:\Program Files\MySQL\MySQL Server 8.0>mysqld --console --skip-grant-tables --shared-memory
2023-04-18T02:17:23.068636Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.22) starting as process 8376
2023-04-18T02:17:23.077728Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file 'C:\Program Files\MySQL\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2023-04-18T02:17:23.102886Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2023-04-18T02:17:23.104836Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2023-04-18T02:17:23.106562Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-04-18T02:17:23.108782Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.22) MySQL Community Server - GPL.
C:\Program Files\MySQL\MySQL Server 8.0>mysqld --console --skip-grant-tables --shared-memory
2023-04-18T02:17:34.512473Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.22) starting as process 8080
2023-04-18T02:17:34.512548Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file 'C:\Program Files\MySQL\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2023-04-18T02:17:34.540343Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2023-04-18T02:17:34.542127Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2023-04-18T02:17:34.543209Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-04-18T02:17:34.546384Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.22) MySQL Community Server - GPL.
C:\Program Files\MySQL\MySQL Server 8.0>mysqld --console --skip-grant-tables --shared-memory
2023-04-18T02:17:36.988495Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.22) starting as process 10996
2023-04-18T02:17:36.988568Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file 'C:\Program Files\MySQL\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2023-04-18T02:17:37.018230Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2023-04-18T02:17:37.020658Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2023-04-18T02:17:37.022340Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-04-18T02:17:37.024609Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.22) MySQL Community Server - GPL.
C:\Program Files\MySQL\MySQL Server 8.0>mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
C:\Program Files\MySQL\MySQL Server 8.0>mysql -uroot -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.22 MySQL Community Server - GPL
Copyright (c) 2000, 2020, 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> use mysql;
Database changed
mysql> mysql> select Host,User,plugin from mysql.user;
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 'mysql> select Host,User,plugin from mysql.user' at line 1
mysql> alter user root@localhost identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.07 sec)
mysql>
mysql> FLUSH PRIVILEGES;
-> alter user root@localhost identified with mysql_native_password by '123456';
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 'PRIVILEGES;
alter user root@localhost identified with mysql_native_password by' at line 1
mysql>
mysql> FLUSH PRIVILEGES;
-> alter user root@localhost identified with mysql_native_password by '123456';
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 'PRIVILEGES;
alter user root@localhost identified with mysql_native_password by' at line 1
mysql>
mysql> FLUSH PRIVILEGES;
-> alter user root@localhost identified with mysql_native_password by 'root';
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 'PRIVILEGES;
alter user root@localhost identified with mysql_native_password by' at line 1
mysql> alter user root@localhost identified with mysql_native_password by 'root'
->
->
-> alter user root@localhost identified with mysql_native_password by 'root'
-> alter user root@localhost identified with mysql_native_password by 'root';
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 'alter user root@localhost identified with mysql_native_password by 'root'
alter ' at line 4
mysql> alter user root@localhost identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.06 sec)
mysql> alter user root@localhost identified with mysql_native_password by 'root';
Query OK, 0 rows affected (0.09 sec)
mysql>
这是 my.ini文件
[mysqld]
#(------这是看博客额外添加的 据说可以跳过密码登录 但是在我这没啥用------- )
skip-grant-tables
# 设置3306端口
port=3306
# 设置mysql的安装目录 ----------是你的文件路径-------------
basedir=C:\Program Files\MySQL\
# 设置mysql数据库的数据的存放目录 ---------是你的文件路径data文件夹自行创建
datadir=C:\Program Files\MySQL\MySQL Server 8.0\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4
标签:Files,8.0,1045,NO,mysql,ERROR,Server,MySQL From: https://blog.51cto.com/u_15941034/6202653