Detailed steps for installing and configuring MySQL 5.7

Detailed steps for installing and configuring MySQL 5.7

1. Download MySQL

1. Log in to the official website of MySQL and download the ZIP compressed package for 64-bit system (https://dev.mysql.com/downloads/mysql/)

2. Unzip the installation package

Unzip the downloaded ZIP archive to any folder. (Here: C:\mysql5.7)

3. Modify the configuration file

Rename the my-default.ini file in the unzipped folder to my.ini.

Open it with a text editor and clear its contents.

Added content (reference Internet):

[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 to basedir=C:\mysql5.7
# Set the storage directory of mysql database data datadir=C:\mysql5.7\data
# 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

Note:

Replace basedir and datadir with your actual paths.

The folder directory after the initial decompression of the compressed package of MySQL version 5.7 does not contain a data folder. Don't worry, it will be initialized and created using commands later. No manual creation is required here.

After the modification is completed, save and exit.

4. Configure environment variables

Add C:\mysql5.7\bin to the Path environment variable (replace it with the actual path of the bin directory)

Note: Separate from the previous environment variables with ;

5. Install MySQL

Run the cmd window as administrator.

Switch to the C:/mysql5.7/bin directory

Enter the following commands in order:

1. mysqld install waits for the prompt that the installation is successful

2. mysqld --initialize initializes the data directory

3. net start mysql to start the service

6. Change the root user's password

After completing the above five steps, run mysql -u root -p. Since the root user has no password by default, just press Enter to enter.

Error message: ERROR 1045 (28000): Access denied for user'root'@'localhost'(using password: NO)

This is because the mysql root user has not set a password. We need to temporarily ignore the permissions and set the root user's password.

Here’s how to do it:

Add a line of statement skip_grant_tables under the [mysqld] entry in the configuration file my.ini

Save and exit, and restart the MySQL service. If you do not restart the MySQL service, there will be no effect.

After restarting, run mysql -u root -p

When prompted to enter the password, just press Enter to enter MySQL

Enter the following SQL statements in order

1.use mysql; show Database changed
2.update user set authentication_string=password("123456") where user="root"; The password in brackets is the password you want to set
3.flush privileges; refresh the database, be sure to refresh
4. quit

Delete or comment out skip_grant_tables in the configuration file my.ini

7. Some settings for first login

You cannot use MySQL directly after logging in for the first time. You need to reset your password again, otherwise an error message will appear.

ERROR 1820 (HY000) : You must SET PASSWORD before executing this statement

Enter the command:

set password=password('123456');

Keep the same password as set in the previous step

After the settings are completed, MySQL can be used normally. At this time, the root user can only connect through the local computer, which is sufficient for learning.

If you need a remote connection, you need to set it up again

The SQL statement is as follows:

use mysql;
show tables;
select host,user from user;
update user set host='%' where user='root';
quit
net stop mysql
net start mysql

Note:

The host column specifies the IP address that the user is allowed to log in through. % is a wildcard. If it is set to %, any IP address can access the root account.

The above is the detailed steps for installing and configuring MySQL 5.7 introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Mysql5.7.14 installation and configuration method operation graphic tutorial (password problem solution)
  • Deploy MySQL 5.7.17 binary installation and multi-instance configuration on CentOS 6.5
  • MySQL 5.7.17 installation and configuration tutorial under Linux (Ubuntu)
  • MySQL 5.7.12 installation and configuration tutorial under Mac OS 10.11
  • MySQL 5.7 installation and configuration tutorial under CentOS7 (YUM)
  • Installation and configuration of Mysql5.7.11 on windows10 (decompressed version)
  • How to configure environment variables after installing mysql5.7 database

<<:  Talk about important subdirectory issues in Linux system

>>:  Native JS music player

Recommend

Tutorial on installing MySQL 5.6 using RPM in CentOS

All previous projects were deployed in the Window...

Install centos7 virtual machine on win10

1. Download VMware Workstation 64 version https:/...

An article teaches you how to use Vue's watch listener

Table of contents Listener watch Format Set up th...

User experience of portal website redesign

<br />From the launch of NetEase's new h...

Summary of learning HTML tags and basic elements

1. Elements and tags in HTML <br />An eleme...

Summary of MySQL commonly used type conversion functions (recommended)

1. Concat function. Commonly used connection stri...

Vue3 Vue Event Handling Guide

Table of contents 1. Basic event handling 2. Send...

Detailed explanation of the application of CSS Sprite

CSS Sprite, also known as CSS Sprite, is an image...

CentOS6.8 Chinese/English environment switching tutorial diagram

1. Introduction People who are not used to Englis...

Steps for Vue3 to use mitt for component communication

Table of contents 1. Installation 2. Import into ...

Discussion on more reasonable creation rules for MySQL string indexes

Preface Regarding the use of MySQL indexes, we ha...

MySQL 5.6.37 (zip) download installation configuration graphic tutorial

This article shares the download, installation an...

Native JS to implement sharing sidebar

This article shares a sharing sidebar implemented...