The latest (2019) MySQL 8.0.18 win64 installation method

This article only explains how to install using a ZIP file

Community version download address: http://dev.mysql.com/downloads/mysql/

To sum it up:
download the installation package, decompress it,
configure environment variables,
add a configuration file,
initialize mysql,
start the mysql service,
log in and change the password (most people will not use the automatically generated string that cannot be remembered)

If there is a problem, first check whether the cmd is started with administrator privileges, if not, please close it and start it with administrator privileges

1. Find the version you want to download and download. The official website recommends the 32-bit version by default. You
can choose to download the 64-bit version yourself. After downloading, decompress it to the location you want to install.
2. Add the decompressed mysql bin directory to the environment variable. Please search "how to add environment variables" by yourself
3. Configure my-default.ini. Don't believe that the higher version of the article mentioned below does not need to be configured.
Configure one yourself. Many articles tell you to configure my.ini. But when I actually installed, I found that the service named my.ini could not be started. To be named my-default.ini

Create a new txt file under the decompressed folder, write the following content and rename it to my-default.ini
**Attention! ! ! ! **Directory changed to your own installation directory

[mysql]
default-character-set=UTF8MB4

[mysqld]
port=3306
basedir=D:\DevSoft\mysql-8.0.18-winx64
#data文件夹可以指定到其它你想存储数据的地方,避免以后删除mysql时数据也被删了
#不然你就记得长个心眼,删除之前复制一份data里*自己创建的*数据库文件
datadir=D:\DevSoft\mysql-8.0.18-winx64\data
#200可以改,指定最大连接数
max_connections=200
character-set-server=UTF8MB4
default-storage-engine=INNODB

UTF8MB4 is mysql statement that I found it is better to use this instead of utf8 in the process of encountering a
pit . The mysqld --initialize -insecure method mentioned in the 4.4w+ reading volume does not know how many people have been harmed. I don't know if it is a mistake or this method has become inapplicable because of time. Insecure means insecure. After reading his article description, I thought it was insecure because there was no initial password. It seems that there are a lot of insecure places. When using this method to start mysql, 5 errors appeared.

If you are installing for the first time, please delete the entire data folder after using this method , and you can delete it without worry, because if you are installing MySQL for the first time (N times of installation failures are counted) and you have not used sql statements to operate or import sql files, then The data folder itself and everything below it is generated during the initialization process, and nothing important will be deleted.

Windows first needs to run cmd with administrator privileges
and right click on the start menu bar to find it. Win10 is powershell, which has an effect.
If you are used to using cmd, enter cmd under powershell, and you will also open cmd with administrator privileges
and execute mysqld --initialize -- user=root --console
root is the user name --console will output initialization information
If successful, the content after the last localhost: of the output information is the password
copy and save it for future use! ! ! . You can't find the err file mentioned in the above article. The new version of mysql must change the location and may even encrypt the storage for security reasons, so remember to copy the password.

The following steps still need to be started under the cmd with administrator privileges
5. Install the service mysql service
mysqld --install
6. Start the service net start mysql
7. Log in to
mysql -h 127.0.0.1 -u root -p press Enter, and then enter the password
127.0.0.1 is localhost,
which was randomly generated when I installed, 4?hsWAb;fjjo, I suspect? It was an unprintable character that caused me to be denied login due to a wrong password.
Refer to this article to solve the problem. [https://www.cnblogs.com/lyhbky/p/10748357.html]
Two points of attention must be paid attention to . The mysqld --shared-memory --skip-grant-tables command used in the article requires the mysql service to be closed (net stop mysql)
After executing this command, you will not be allowed to enter the next command. It is not because it has not been executed or is stuck. This is the effect of this command, so at this time you need to open another one that starts with administrator privileges cmd window to enter other commands
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' Generally, everyone will copy this command in the article to try to solve the problem, but please note that after this command, add an English semicolon and return Car , otherwise sql will not execute this command but will judge that you have not finished typing and continue to wait for input.
even useALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

7. The automatically generated password is very messy, change it to your own password
setpassword=password('123456')
Since I changed the password through the method in 6, I have not verified the correctness of this method, I will leave it to you to verify .

Guess you like

Origin blog.csdn.net/qq_36376711/article/details/102788509