Win10 install MySQL8 (64-bit) compressed version

(Because the installation of mysql8 is slightly different from the previous version, this article is modified on the basis of the previous article " Win7 installs MySQL 64-bit decompressed version ")

The Windows version of MySQL is divided into two types: the ims installation version and the zip compressed version. Among them, the installation version can be directly run and installed, while the compressed version is more complicated, and needs to be configured after decompression.

1. Download the latest version of MySQL

Download the latest 64-bit Windows compressed version from MySQL's official website, the download link is  mysql-8.0.21-win64.zip

2. Unzip

Unzip a directory, the path after I unzip is D:\database\mysql\mysql-8.0.21-winx64

3. Configure system environment variables

On the Win10 desktop, right-click Properties, on the left side of the pop-up System Basic Information dialog box, click Advanced System Settings, click the "Environment Variables (N)..." button at the bottom right, and in System Variables, modify the value of the Path variable (If there is no Path variable, create a new one), add the bin path of mysql (to go to the bin directory), if Path already has other variable values, enter it at the end; (English semicolon), add the bin directory of mysql

Path             D:\database\mysql\mysql-8.0.21-winx64\bin

4. Modify the configuration file

In the mysql decompression directory D:\database\mysql\mysql-8.0.21-winx64, add the my.ini configuration file, specify the installation path and data path basedir, datadir, the configuration file is as follows

[mysqld] 
basedir = D:\database\mysql\mysql-8.0.21-winx64
datadir = D:\database\mysql\mysql_data
port = 3306
server_id = 1

 

5. Initialize the database

Enter the CMD of the system as an administrator, or click Windows PowerShel (admin) in the pop-up menu with win+x, switch the path to the mysql decompression directory 

cd /d D:\database\mysql\mysql-8.0.21-winx64\bin

Execute the command to initialize

mysqld --initialize --console

After execution, a root login password will be generated at the end. Write this down and use it later when you log in to root for the first time.

6. Installation service

Execute mysqld -install in the bin directory to install and create a windows service

D:\database\mysql\mysql-8.0.21-winx64\bin>mysqld -install
Service successfully installed.

Open the Windows "Services" management interface, you can see the MySQL service, start it

You can also execute the following command to start the mysql service

net start mysql

 

7. Enter mysql and modify the root password

Use the password you just initialized to enter, and then modify the root default password

D:\database\mysql\mysql-8.0.21-winx64\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.18

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

After mysql version 8.0, the password function setting of MySQL has been cancelled, so the method of setting password to modify the password is not feasible. Use the alter user command to directly change the root password, and the following prompt will always appear:

mysql> ALTER USER "root"@"%" IDENTIFIED BY "yourpassword";

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

Obviously using alter user to reset the password, but always reminding to use the alter user to reset the password, confused. After investigation, it is necessary to execute the following password reset statement first

alter user user() identified by 'yourpassword';

Then change the root password again.

ALTER USER "root"@"%" IDENTIFIED BY "yourpassword";

 

8. You're done

Now that the installation is complete, you can build databases, build users, and play mysql happily.

It should be noted that the way mysql8 creates users and authorization is also different from before. The script is as follows:

mysql> create database mydb;
Query OK, 1 row affected (0.00 sec)

mysql> CREATE USER 'myname'@'%' IDENTIFIED BY 'yourpassword';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON mydb.* TO 'myname'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mydb               |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql>

 

If Chinese garbled characters appear when importing the sql file, first use status to check the encoding, and then use utf8 to log in

mysql -u yourname -p --default-character-set=utf8mb4

After logging in, use source to import the sql file in mysql.

 

Welcome to follow my WeChat public account "Big Data and Artificial Intelligence Lab" (BigdataAILab) for more information

 

Recommended related reading

1. AI combat series

2. Dahua Deep Learning Series

3. Graphical AI series

4. AI talk

5. Big data super detailed series

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324125225&siteId=291194637