记一次mysql 8 在windows的安装记录

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

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

C:\Windows\system32>mysqld --initialize --console
2020-05-12T11:43:30.434174Z 0 [System] [MY-013169] [Server] E:\Program Files\mysql-8.0.13-winx64\bin\mysqld.exe (mysqld 8.0.13) initializing of server in progress as process 13960
2020-05-12T11:43:47.037051Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: PBycMV=kI96e
2020-05-12T11:43:56.874712Z 0 [System] [MY-013170] [Server] E:\Program Files\mysql-8.0.13-winx64\bin\mysqld.exe (mysqld 8.0.13) initializing of server has completed

C:\Windows\system32>net start mysql
发生系统错误 1058。

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


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

C:\Windows\system32>mysql --install
mysql: [ERROR] unknown option '--install'.

C:\Windows\system32>mysqld --install
The service already exists!
The current server installed: "C:\Program Files (x86)\MySQL\MySQL Server 5.1\bin\mysqld" --defaults-file="C:\Program Files (x86)\MySQL\MySQL Server 5.1\my.ini" MySQL

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

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

C:\Windows\system32>mysqld --initialize

C:\Windows\system32>mysqld --initialize --console
2020-05-12T11:56:56.475278Z 0 [System] [MY-013169] [Server] E:\Program Files\mysql-8.0.13-winx64\bin\mysqld.exe (mysqld 8.0.13) initializing of server in progress as process 7648
2020-05-12T11:56:56.478041Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2020-05-12T11:56:56.502544Z 0 [ERROR] [MY-013236] [Server] Newly created data directory E:\Program Files\mysql-8.0.13-winx64\data\ is unusable. You can safely remove it.
2020-05-12T11:56:56.515084Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-05-12T11:56:56.519681Z 0 [System] [MY-010910] [Server] E:\Program Files\mysql-8.0.13-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.13)  MySQL Community Server - GPL.

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


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

Copyright (c) 2000, 2018, 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
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.55 sec)

mysql> quit
Bye

C:\Windows\system32>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.13 MySQL Community Server - GPL

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



出现的问题,我之前装过mysql,然后反反复复的卸载过后。系统中存在一些残留的配置会导致再次安装出现问题。

1.卸载以前的服务;

2.更改环境变量,删除以前的环境变量;

3.在根目录下新建一个my.ini文件

[mysql]

# 设置mysql客户端默认字符集

default-character-set=utf8


[mysqld]

#设置3306端口

port = 3306
# 设置mysql的安装目录

basedir=D:\Program Files\mysql-8.0.13-winx64
# 允许最大连接数

max_connections=200

# 服务端使用的字符集默认为8比特编码的latin1字符集

character-set-server=utf8

# 创建新表时将使用的默认存储引擎

default-storage-engine=INNODB

注意:第一次登陆MYSQL时,会提示要求输入初始密码,这是考虑安全因素,命令:mysqld --initialize会随机生成密码。

需要自己保存起来,登陆的时候要用。

操作截图:

记一次mysql 8 在windows的安装记录_第1张图片

 

 

 

记一次mysql 8 在windows的安装记录_第2张图片

 

 

 记一次mysql 8 在windows的安装记录_第3张图片

你可能感兴趣的:(服务器)