Error in command mysqld --initialize --console during mysql installation

I just reinstalled the database (there were problems again and again)
and suddenly this error appeared

C:\Users\ringo>mysqld --initialize --console
2021-12-28T14:48:37.389038Z 0 [System] [MY-013169] [Server] E:\mysql-8.0.27-winx64\bin\mysqld.exe (mysqld 8.0.27) initializing of server in progress as process 31376
2021-12-28T14:48:37.390380Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2021-12-28T14:48:37.391307Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2021-12-28T14:48:37.391319Z 0 [ERROR] [MY-013236] [Server] The designated data directory E:\mysql-8.0.27-winx64\ is unusable. You can remove all files that the server added to it.
2021-12-28T14:48:37.392296Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-12-28T14:48:37.392611Z 0 [System] [MY-010910] [Server] E:\mysql-8.0.27-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.27)  MySQL Community Server - GPL.

I don't know why it went wrong. It turned out that the ini file was wrongly written...
Let's review the installation process here.

1. Download mysql from the official website and put it in the root directory

2. Configure environment variables


Add the bin Path of the Mysql_Home installation directory in the system variables and user variables respectively
Add the bin of the Mysql_Home installation directory

3. Create a new txt file and enter the following content and then change it to an ini file

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir= E:/mysql-8.0.27-winx64
# 设置mysql数据库的数据的存放目录
datadir= E:/mysql-8.0.27-winx64/data
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

4. The administrator runs cmd to execute the command, and it succeeds.

The current statement is the password of the initial database

2021-12-28T14:50:44.083257Z 6 [Note] [MY-010454] [Server] 
A temporary password is generated for root@localhost: 8Id3)k;*>:aq

5. mysqld --install command line installation

But I don’t know why I still can’t get in after entering the correct password, and it still doesn’t work to skip the password detection with the common method on the Internet, so I finally read a post and entered a new sentence.

mysqld --console --skip-grant-tables --shared-memory

After entering, open a new cmd window to use mysql

Guess you like

Origin blog.csdn.net/weixin_42818410/article/details/122204774