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

Introduction to Docker Quick Deployment of SpringBoot Project

1. Install Docker First open the Linux environmen...

In-depth understanding of uid and gid in docker containers

By default, processes in the container run with r...

Detailed explanation of how to reduce memory usage in MySql

Preface By default, MySQL will initialize a large...

HTML sample code for implementing tab switching

Tab switching is also a common technology in proj...

Practical record of solving MySQL deep paging problem

Table of contents Preface Why does limit deep pag...

Implementing a simple calculator with javascript

This article example shares the specific code of ...

How to solve the margin collapse problem in CSS

First, let's look at three situations where m...

Vue conditional rendering v-if and v-show

Table of contents 1. v-if 2. Use v-if on <temp...

How to set up cross-domain access in IIS web.config

Requirement: The page needs to display an image, ...

Vue Beginner's Guide: Environment Building and Getting Started

Table of contents Initial Vue Building a Vue deve...

Detailed explanation of the use of umask under Linux

I recently started learning Linux. After reading ...

How to write high-quality JavaScript code

Table of contents 1. Easy to read code 1. Unified...

MySql 8.0.11 installation and configuration tutorial

Official website address: https://dev.mysql.com/d...