Detailed steps to configure my.ini for mysql5.7 and above

Detailed steps to configure my.ini for mysql5.7 and above

There is no data directory, my-default.ini and my.ini files in the unzipped package of Windows 64-bit MySQL 5.7 or above, and the solution to the problem that the service cannot be started and the method to change the initial password.

MySQL official website download address

Take version 5.7.20 as an example

First, after the installation package is unzipped, there is no data folder and my-default.ini mentioned in the online tutorial, as shown in the figure below

Please refer to the online tutorial to configure the environment variables. This is generally no problem. That is, add the path where the MYSQL decompression package bin is located in the Path of the environment variable. Mine is:

D:\softnew\MYSQL\mysql-5.7.20-winx64\bin

Pay attention to the following points:

(1) It is not important whether the my-default.ini file exists or not. The key is to create a new my.ini file in the root directory. The specific content is as follows:

[mysql]

# Set the default character set of the mysql client to default-character-set=utf8 
[mysqld]
#Set port 3306 port = 3306 
# Set the installation directory of mysql basedir=D:\\softnew\\MYSQL\\mysql-5.7.20-winx64
# Maximum number of connections allowed max_connections=200
# The default character set used by the server is the 8-bit latin1 character set character-set-server=utf8
# The default storage engine that will be used when creating a new table default-storage-engine=INNODB

You can copy and paste directly, mainly modify the path after basedir, note that the path is \\ instead of \

(2) Please do not create a data folder yourself

Many tutorials on the Internet suggest creating a new empty data folder and then adding a sentence to the my.ini file:

# Set the storage directory of mysql database data datadir=D:\\softnew\\MYSQL\\mysql-5.7.20-winx64\\data

This will cause the service to fail to start. Do not add this sentence, and do not create a new data folder yourself. Let mysql automatically generate data. Specifically:

1) Open the cmd command window as an administrator (directly opening cmd to run may result in an error), and enter the bin directory of the MySQL installation directory . Then enter the command mysqld install to display success

2) Enter: mysqld –initialize again. There should be no prompt at this time.

3) Enter again: net start mysql and it will show

Finally, the contents of the data folder should be displayed as follows:

Note: When you log in to MYSQL for the first time, you will be prompted to enter an initial password. This is for security reasons. The command: mysqld –initialize will randomly generate a password.

The initial password is in the xxx.err file in the data folder in the above picture. You can open it with Notepad and use ctrl+f to find the following line of records:

[Note] A temporary password is generated for root@localhost: NZ+uhXPq1zN.

NZ+uhXPq1zN. is the initial password (note that the . should not be omitted)

After entering, you can use the following command to modify it. Here the password is changed to root:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

This is version 5.7.22, and the display is basically as follows:

Thanks!

Wonderful topic sharing:

MySQL different versions installation tutorial

MySQL 5.7 installation tutorials for various versions

MySQL 5.6 installation tutorials for various versions

mysql8.0 installation tutorials for various versions

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Solution to the lack of my.ini file in MySQL 5.7
  • Mysql5.7 my.ini file loading path and data location modification method under windows7

<<:  Detailed explanation of the pitfalls of Apache domain name configuration

>>:  JavaScript mobile H5 image generation solution explanation

Recommend

How to connect a Linux virtual machine to WiFi

In life, the Internet is everywhere. We can play ...

TypeScript uses vscode to monitor the code compilation process

Install Install ts command globally npm install -...

Tomcat parses XML and creates objects through reflection

The following example code introduces the princip...

MySQL data insertion efficiency comparison

When inserting data, I found that I had never con...

How to deploy Spring Boot using Docker

The development of Docker technology provides a m...

MySQL data migration using MySQLdump command

The advantages of this solution are simplicity an...

How to shrink the log file in MYSQL SERVER

The transaction log records the operations on the...

Not all pop-ups are rogue. Tips on designing website pop-ups

Pop-up news is common in domestic Internet servic...

Solution to the problem of invalid width setting for label and span

By default, setting width for label and span is in...

Detailed explanation of script debugging mechanism in bash

Run the script in debug mode You can run the enti...

Vue implements adding watermark to uploaded pictures

This article shares the specific implementation c...

Introduction to several ways to introduce CSS in HTML

Table of contents 1. Embed CSS styles directly in...

A brief discussion on whether MySQL can have a function similar to Oracle's nvl

Use ifnull instead of isnull isnull is used to de...