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

Vue implements infinite loading waterfall flow

This article example shares the specific code of ...

Complete steps of centos cloning linux virtual machine sharing

Preface When a Linux is fully set up, you can use...

How to configure multiple tomcats with Nginx load balancing under Linux

The methods of installing nginx and multiple tomc...

Move MySQL database to another disk under Windows

Preface Today I installed MySQL and found that th...

How to use vuex in Vue project

Table of contents What is Vuex? Vuex usage cycle ...

ul list tag design web page multi-column layout

I suddenly thought of this method when I was writi...

Detailed steps to install MySQL 5.6 X64 version under Linux

environment: 1. CentOS6.5 X64 2.mysql-5.6.34-linu...

Docker learning method steps to build ActiveMQ message service

Preface ActiveMQ is the most popular and powerful...

MySQL free installation version configuration tutorial

This article shares the MySQL free installation c...

Three properties of javascript objects

Table of contents 1. writable: writable 2. enumer...

An article to solve the echarts map carousel highlight

Table of contents Preface toDoList just do it Pre...

The solution record of Vue failing to obtain the element for the first time

Preface The solution to the problem of not being ...