管理员身份运行powershell
Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。
尝试新的跨平台 PowerShell https://aka.ms/pscore6
PS C:\Users\Administrator> mysql
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
PS C:\Users\Administrator> mysqld -install
The service already exists!
The current server installed: "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe" mysql
PS C:\Users\Administrator> mysqld -install
The service already exists!
The current server installed: "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe" mysql
PS C:\Users\Administrator> mysqld --remove mysql
Service successfully removed.
PS C:\Users\Administrator> mysqld -install
The service already exists!
The current server installed: "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe" mysql
PS C:\Users\Administrator> net start mysql
发生系统错误 1058。
无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动。
PS C:\Users\Administrator> mysqld --initialize-insecure
2021-11-24T08:53:32.858504Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-11-24T08:53:32.860503Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2021-11-24T08:53:32.860503Z 0 [ERROR] Aborting
PS C:\Users\Administrator> net start mysql
发生系统错误 1058。
无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动。
PS C:\Users\Administrator> mysqld --remove mysql
Failed to remove the service
PS C:\Users\Administrator> mysqld --install mysql --defaults-file=C:\Program Files\MySQL\my.ini
PS C:\Users\Administrator> net start mysql57
MySQL57 服务正在启动 .
MySQL57 服务已经启动成功。
PS C:\Users\Administrator> mysql -h 127.0.0.1 -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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> show databases();
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 '()' at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| blog |
| db2019 |
| design |
| homework |
| jeecg-boot |
| lc-cc |
| loginregist |
| menagerie |
| mysql |
| nacos |
| performance_schema |
| pig |
| pig_codegen |
| pig_config |
| pig_demo |
| pig_job |
| pythonmysql |
| qiolou |
| sakila |
| springboot |
| springcloud |
| starter |
| sys |
| test |
| vueblog |
| world |
+--------------------+
27 rows in set (0.01 sec)
mysql>