The computer has been reconfigured many times. This is a MySQL installation record post for easy reference.
Download the installation package from the official website for local configuration
Download address
: Unzip the downloaded zip package
Add the configuration my.ini file to the unzipped file.
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\\software\\package\\MySQL
# 设置mysql数据库的数据的存放目录
datadir=D:\\software\\package\\MySQL\\Data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4
Configure system environment variables
Configure the path of the decompression directory to the system variable path
Initial installation
Enter mysqld --initialize --console in the cmd window.
The last line contains the initial password. This needs to be copied and used to log in to mysql later.
Start mysql
Enter the net start mysql command in cmd to start mysql
and log in mysql -u root -p
change Password
1. Knowing the initial password
2. If you don’t know the initial password
First stop the mysql service
cmd window => net stop mysql
skip permission authentication
mysqld --shared-memory --skip-grant-tables
Log in to mysql in a new window
mysql -u root -p
Just press Enter, the password has been skipped
use mysql;
update user set authentication_string='' where user='root';
change Password
flush privileges;
Refresh permissions.
Finally, remember to restart mysql in the cmd window.
net start mysql
Next, you can try to log in to MySQL.