1, download MySQL

  • Version: MySQL Community Server

  • Download it at https://dev.mysql.com/

2. Decompress the installation package

Decompress the downloaded installation package to the installation directory on your PC

3. Configure the my.ini file

Ini file. This is the official configuration file sample. Copy this file to the same directory and rename it to my.ini.

  • Copy the following into my.ini:
[mysql]

Mysql client default character set

default-character-set=utf8

[mysqld]

Set port 3306

port = 3306

Set mysql installation directory

basedir=E:\mysql

Mysql > select * from 'root' where 'data' is stored

datadir=E:\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 to use when creating new tables

default-storage-engine=INNODB

Copy the code

4, Install mysql

Open the CMD window as the administrator, go to the bin directory of mysql, and run the following command:

mysqld install  
Copy the code

To uninstall the service, enter the following command:

mysqld -remove
Copy the code

After the installation is successful, enter the following command:

mysqld --initialize
Copy the code

This step is used to initialize the data directory. After the official compressed package is decompressed, the data folder is automatically generated in the root directory. Sometimes, a message may be displayed indicating that you do not have the write permission in the non-root directory.

Finally, enter the command to start the service:

net start mysql
Copy the code

5. Set the password of the root administrator

In mysql, the password of user root cannot be empty. In mysql, there is no password for user root.

Win +R, type services. MSC, open service, find MySQL service, close it. Or run the net stop mysql command to stop the mysql service.

Go to the bin directory again and enter the following command:

mysqld --defaults-file="E:\mysql\my.ini" --console --skip-grant-tables
Copy the code

This is the safe mode to open mysql. (This CMD does not close)

Run the following command to enter the bin directory of mysql:

mysql -u root -p
Copy the code

Then CMD displays:

Enter the password:Copy the code

Press Enter to Enter the mysql database.

Enter the following SQL statement:

use mysql; Display :Database changed, if error, use the command: SET PASSWORD = PASSWORD('123456');


update user set authentication_string=password("123") where user="root"; Query OK,1 rows affected(0.01sec) rows matched:1 Changed:1 Warnings:1 Flush PRIVILEGES; Query OK,0 rows affected (0.00 SEC) quitCopy the code

The password of user root has been set to 123.

The exit command is used to exit the mysql console

Finally, to make it easier to start mysql later, configure the environment variable, Path append:

; E:\mysql\bin;Copy the code

Net statrt mysql server net statrt mysql server net statrt mysql server net statrt mysql server net statrt mysql server net statrt mysql server

  mysql -u root -p

  123
Copy the code

That’s it.

6. After the first run, set common parameters:

1) After login, set the password of user root again in normal mode.

set password=password('123');
Copy the code

Mysql > alter database root;

  use mysql;

  show tables;

  select host,user from user;

  update user set host=The '%' where user='root';

  quit

  net stop mysql

  net start mysql
Copy the code

MySQL is installed and ready to use.