MYSQL database installation

Installation environment: Win10 64 bit
Software version: MySQL 5.7.24 decompressed version

1. Download

Click on the link below:
https://downloads.mysql.com/archives/community/

Select the version corresponding to your system digits and click Download on the right, then you will enter another page, and you can also find it near the bottom of the page as shown in the figure below Shown location:

img

Regardless of the login and registration buttons above, just click No thanks, just start my download. to download.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture directly Upload (img-kvpWa3Rz-1684636121039)(.\imgs\image-20201109134805641.png)]

2. Install (unzip)

After the download is complete, what we get is a compressed package. After decompressing it, we can get the software body of MySQL 5.7.24 (just a folder), and we can put it in the location you want to install.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture directly Upload (img-AGww5SBY-1684636121040)(.\imgs\image-20201109134948046.png)]

3. Configuration

1. Add environment variables

There are many options in the environment variable, here we only use the Path parameter. Why add environment variables at the beginning of initialization?
Enter the name of an executable program in the black box (that is, CMD), and Windows will first search for it in the path pointed to by Path in the environment variable. If it finds it, it will execute it directly. Find it in the current working directory. If it is not found, an error will be reported. The purpose of adding environment variables is to be able to directly call related programs in MySQL in any black box without always modifying the working directory, which greatly simplifies the operation.

Right-click This ComputerProperties, click Advanced System Settings

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture directly Upload (img-Mb4rPQLt-1684636121042)(.\imgs\1556823-20181220220242472-524708778.png)]

Click on Environment Variables

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture directly Upload (img-pszxPvVp-1684636121043)(.\imgs\1556823-20181220220359609-736422950.png)]

Create a new MYSQL_HOME in system variables

Find and double-clickPath in System Variables

Click New

Finally click OK.

How to verify whether the addition was successful?

Right-click the start menu (the lower left corner of the screen), select Command Prompt (Administrator), open the black box, type mysql, and press Enter.
If it prompts Can't connect to MySQL server on 'localhost', it proves that the addition is successful;
If it prompts mysql is not an internal or external command, nor is it an operable program or batch file, it means that the addition failed, please check the steps again and try again.

2. Create a new configuration file

Create a new text file with the following content:

[mysql]
default-character-set=utf8

[mysqld]
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Save the above text file as, select all files (*.*) in the save type, the file name is my.ini, and the storage path is MySQL’s Root directory (for example, mine is D:\software\mysql-5.7.24-winx64, modify according to your own MySQL directory location).

The above code means that the default encoding set of the configuration database is utf-8 and the default storage engine is INNODB.

3. Initialize MySQL

Type mysqld --initialize-insecure in the black box just now, press Enter, and wait for a while. If there is no error message (as shown in the figure below), it proves that there is no problem with the initialization of the data directory. At this time Then check that the data directory has been generated under the MySQL directory.

mysqld --initialize-insecure

tips: If the following error occurs

It is caused by insufficient permissions, go to C:\Windows\System32 to run cmd.exe as an administrator


4. Register MySQL service

Type mysqld -install in the black box and press Enter.

mysqld -install

The MySQL service is now installed on your computer.

MySQL server

5. Start MySQL service

Type net start mysql in the black box and press Enter.

net start mysql // start mysql service
    
net stop mysql // stop mysql service

6. Modify the default account password

Type mysqladmin -u root password 1234 in the black box, where 1234 refers to the password of the default administrator (that is, the root account), and you can modify it to your liking .

mysqladmin -u root password 1234

So far, the MySQL 5.7 decompressed version is installed!

4. Login to MySQL

Right-click the Start menu, select Command Prompt, and open the black box.
Enter in the black box, mysql -uroot -p1234, press Enter, the following picture appears and the lower left corner is mysql>, then the login is successful.

mysql -uroot -p1234

Here you can start your MySQL journey!

exit mysql:

exit
quit

Login parameters:

mysql -u username -p password -h the ip address of the mysql server to be connected (default 127.0.0.1) -P port number (default 3306)

5. Uninstall MySQL

If you want to uninstall MySQL, it’s easy too.

Right-click the start menu, select Command Prompt (Administrator), and open the black box.

  1. Type net stop mysql and press Enter.
net stop mysql

  1. Then type mysqld -remove mysql and press Enter.
mysqld -remove mysql

  1. Finally, delete the MySQL directory and related environment variables.

So far, MySQL uninstallation is complete!