Mysql 5.7 version installation (win10)

1. Download:

https://downloads.mysql.com/archives/community/

Install on D drive

2. Environment variable configuration:

 

 

 

 

 

 3. Initialization

Directly double-click to run bin/mysql.exe installation error?

(1) Run cmd as an administrator

 

 (2) Execute the following command in the bin directory of mysql

//cd bin目录
C:\Windows\system32>d:

D:\>cd mysql-5.7.24-winx64\bin

//安装文件

D:\JavaWebSoftware\mysql-5.7.23-winx64\bin>mysqld --install MySQL

Service successfully installed.

4. Start the service

//启动服务

D:\JavaWebSoftware\mysql-5.7.23-winx64\bin>net start mysql

报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Solution: Add a sentence anywhere in the my.ini file (skip-grant-tables)

Question: What if there is no my.ini file?

Solution: configure my.ini file

(1) Suspend the mysql service:

Right click, pause service

 (2) Create a new my.ini configuration file:

In the root directory of the mysql program, create a new my.ini blank file, open it with Notepad, and copy the following content into it

# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[client]
default-character-set = utf8
[mysql]
default-character-set = utf8
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8
init_connect='SET NAMES utf8'
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = C:\Program Files\MySQL\MySQL Server 5.7
datadir = C:\Program Files\MySQL\MySQL Server 5.7\data
port = 3306
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 16M
read_rnd_buffer_size = 16M 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#skip-grant-tables

Among them, basedir and datadir are modified according to the actual MySql installation location on your computer

(3) Regenerate the data file

Continue to execute the following command in the originally opened cmd window:

mysqld --initialize-insecure --user=mysql

(4) Reinstall the mysql service and bind the my.ini configuration file at the same time
Execute the command in the cmd window:

mysqld --install "MySql57" --defaults-file="D:/MySQL/MySQL Server 5.7/my.ini"

Note: MySql57 is the MySQL service name that you can rename

If it appears: **The service already exists!**, it means that the MySQL service has been installed successfully

(5) Start the MySQL service

net start MySql

6: Reset the password
(1) Login password
mysql -u root -p
At this time, the password is empty, no need to fill in, just press Enter: if
the password is empty, you need to add the following code anywhere in the my.ini file:

skip-grant-tables

(2) Modify the password of the root user.
The password can only be changed after selecting the MySQL database

use mysql;
update mysql.user set authentication_string=password("你的密码") where user="root";

(3) Refresh permissions and exit

flush privileges;
quit

Guess you like

Origin blog.csdn.net/weixin_57092157/article/details/120185908