Download zip compression package#
Download link:
https://dev.mysql.com/downloads/mysql/5.7.html#downloads
Extract to installation address
Create a configuration file in the extraction address
Create a new text file and modify the content to the following configuration content (where the installation path is the just extracted path)
Change the configuration file name to my.int
[mysql]
# Set the default character set for the mysql client
default-character-set=utf8
[mysqld]
# Set the port to 3306
port = 3306
# Set the installation directory of mysql, fill in your own installation address
basedir= D:\helloword\environment\DataBase\mysql-8.4.0-winx64
# Set the data storage directory for mysql databases
datadir= D:\helloword\environment\DataBase\mysql-8.4.0-winx64\data
# Allow maximum connections
max_connections=200
# The character set used by the server is the default 8-bit encoded latin1 character set
character-set-server=utf8
# The default storage engine to be used when creating new tables
default-storage-engine=INNODB
Configure environment variables#
Open environment configuration
Create a new environment variable
Configure environment variables to path
ps. Generally, after configuring environment variables, you need to restart your computer for the changes to take effect. If you encounter an error saying that the command does not exist when executing the mysql command in the following steps, you need to restart your computer.
Initialize the database#
Open the cmd command line with administrator privileges
Execute the following commands in order
:: Initialize
mysqld --initialize --user=mysql --console
:: Install the service
mysqld --install
:: Start the service
net start mysql
:: Log in using the initialized account
mysql -uroot -p
:: Enter the generated account password
xxxxx
Change password and daily use#
After successful login, change the password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
For daily login
:: Start the mySQL service
net start mysql
:: Log in with the account mysql -uxxx (account) -p (xxx) password
mysql -uroot -proot
:: Show databases
show databases;
:: Exit the login
exit;
:: Stop the mySQL service
net stop mysql