MySQL8.0 green version - the purest installation experience (avoiding the 'embarrassing' situation where you can only redo the system if you can't uninstall it)

Table of contents

1. The whole process of MySQL8.0 green version installation

1. Download the installation package

2. Unzip the compressed package

3. Create an empty data folder

4. Create my.ini file

5. Edit my.ini file

 6. Configure environment variables

 7. Environment initialization and install

8. Start the MySQL service

9. Login to MySQL

10. Modify the password

11. Refresh permissions

12. Login verification

2. Open MySQL remote access

1. Modify permissions

2. Remote connection confirmation

3. Through the tool connection test

3. Delete MySQL perfectly

1. Close the MySQL service

2. Delete the registry

3. Delete the MySQL service

4. Abnormal

Error running mysqld --initialize-insecure --user=mysql


1. The whole process of MySQL8.0 green version installation

1. Download the installation package

Official MySQL download address:

MySQL :: Download MySQL Community Server

The version selected here is: MySQL Community Server 8.0.34

Optimistic, we use it ourselves, just use the community version. If you go to the public network, you must buy a server.

No need to log in, just click to download.

2. Unzip the compressed package

Unzip it after downloading

Decompression effect.

3. Create an empty data folder

Here we need to create a [data] empty folder.

4. Create my.ini file

The official website does not provide the my-default.ini file in the binary package since 5.7.18. We need to create a my.ini file ourselves.

5. Edit my.ini file

The following code needs to manually rewrite the specific location by yourself. A total of 3 positions have been modified, so be optimistic.

this is mine.

[mysqld]
basedir ="D://save//exe//sql//mysql-8.0.34-winx64"   # 设置mysql的安装目录
datadir ="D://save//exe//sql//mysql-8.0.34-winx64//data"   # 设置mysql数据库的数据的存放目录,必须是data,或者是//xxx/data

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

#服务端的编码方式
character-set-server=utf8mb4
[client]
#客户端编码方式,最好和服务端保存一致
loose-default-character-set=utf8mb4

# 端口号设置
port=3306

[WinMySQLadmin]  
Server = "D://save//exe//sql//mysql-8.0.34-winx64//bin//mysqld.exe"

 6. Configure environment variables

Open My Computer, go to Properties, and select Advanced System Settings.

Advanced System Settings 

The complete steps of adding environment variables can be added in the order of the pictures.

 7. Environment initialization and install

Here you need to enter the command. Since we have set the environment variable, we can directly open the administrator's cmd and run the following command.

mysqld --initialize-insecure --user=mysql
mysqld -install

Be sure to use administrator status.

running result:

Files under the [data] folder after initialization.

It can be seen that the generation is successful, and the registration information of MySQL will be added in the registry after generation.

8. Start the MySQL service

net start mysql

Start effect, success.

9. Login to MySQL

Since no password is set, the current password is empty. The login statement is:

mysql -uroot -p

When encountering password, press Enter directly.

10. Modify the password

The mysql library is required.

use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

In this case, the pwd:root corresponding to userName:root is convenient and easy to use.

11. Refresh permissions

This command to refresh permissions must be remembered, it is often used.

flush privileges;
exit;

12. Login verification

Use the pwd we set to log in and confirm that the login is successful.

2. Open MySQL remote access

1. Modify permissions

We use the mysql library, modify the [host] of the root user to [%], and then refresh the permissions to complete the change of remote access permissions.

Full statement:

use mysql;
select User,authentication_string,Host from user;
update user set host='%' where user='root';
flush privileges;
select User,authentication_string,Host from user;

2. Remote connection confirmation

The parameters in the login method need to add -h to access the ip address

mysql -uroot -h 192.168.0.101 -p

We set pwd, so pwd input is also required.

You can see that the login is successful.

3. Through the tool connection test

Here we pass the Navicat Premium connection test, and we can see that the access is successful.

3. Delete MySQL perfectly

1. Close the MySQL service

Here you can close it directly through the stop command.

net stop mysql

Note the use of start and stop.

2. Delete the registry

Open the registry [regedit].

Path 1:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\EventLog\Application\MySQLD Service

Path 2:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\MySQLD Service

3. Delete the MySQL service

Excuting an order

mysqld -remove

If you see [successfully removed], it means the deletion is successful.

Look at your own needs. Personally, I don’t recommend deleting the local MySQL, keep it for use, after all, the local files don’t matter, keep one my.ini file for backup.

4. Abnormal

Error running mysqld --initialize-insecure --user=mysql

Explain that our [my.ini] file has abnormal spaces or something, go to see if there is any abnormality in the my.ini file, check it carefully, use [//] to replace [\] as the separator of the path.

Guess you like

Origin blog.csdn.net/feng8403000/article/details/132183506