Install or upgrade the latest version of MySQL under Windows

1. Download mysql from the official website : MySQL :: Download MySQL Community Server https://dev.mysql.com/downloads/mysql/

 

Unzip after downloading;
 

2. Configure the initialized my.ini file (there is no such file in the newly decompressed directory)

my.ini file:

The edited content is as follows:

 

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\mysql-8.0.30-winx64
# 设置mysql数据库的数据的存放目录,在安装mysql-5.7.30-winx64.zip版本的时候,此配置不可添加,将下面一行配置注释掉即可,否则mysql将无法启动。
datadir=D:\mysql-8.0.30-winx64\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
# 关闭ssl
skip_ssl
# 配置时区
default-time_zone='+8:00'
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8

3. Configure environment variables

This computer—>Properties—>Advanced System Settings—>Environment Variables—>Path in User Variables (double-click)—>Edit (add the bin directory under the mysql installation directory). The specific steps are as follows:
(I usually add both user variables and system variables)

 

4. Modify the registry (skip if not installed before)

MySQL has been installed before, open the MySQL registry and modify the configuration to the current version of MySQL, run regedit on Windows+R to open the registry, and enter the MySQL registry path to modify:

Then, if you are using the database, first stop the service with the command net stop mysql, enter cmd in the bin directory of the old version of MySQL, open cmd as an administrator , and execute mysqld --remove mysql to configure the service settings of the old MySQL version before outputting :

5. Install new version mysql

(1) Open cmd and run it with administrator privileges
(2) Initialize the database
and enter the bin directory of the MySQL installation directory in cmd, and execute the command:

mysqld --initialize --console

After the execution is complete, the initial default password of the root user will be printed, for example:

(3) Installation service:
Execute the command in the bin directory of the MySQL installation directory:

mysqld --install mysql

When the service name is not specified, the default service name is mysql.
The successful execution is as follows:

After the installation is complete, you can start the MySQL service with the command net start mysql.

net start mysql

After success will appear:

If unsuccessful, start the service if the following occurs:

Visit vcruntime140_1.dll Free Download | DLL‑files.com to download the latest version of VCRUNTIME140_1.DLL,

 

After downloading, put the decompressed file directly into the bin subdirectory of MySQL. Re-run the command: net start mysql

If unsuccessful, start the service if the following occurs:

Explain that when I was using mysql recently, I found that after entering net satrt mysql in cmd, it was displayed that the MySql service was starting MySql service could not be started. The service did not report any error solution. When I found out later, port 3306 was occupied

Solution:

(1): Use the netstat -ano command to view and find the PID value corresponding to port 3306

(2): Use  the TASKKILL  /F /PID command to end the process, followed by a string of numbers, which is the PID value found in the first step

(3): Then use the net start mysql command to complete the operation

 

 

5. Change password

Enter in the bin directory:

mysql -u root -p

You will be prompted to enter the password: fill in the initialization password to enter the MySQL command mode (if there is no password, just press Enter to enter)

 To change the password, execute the command in MySQL:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';

Change the password, pay attention to the ";" at the end of the command, this is the syntax of mysql
and the new password must be quoted;

At this point, the installation and deployment is complete.

 

Guess you like

Origin blog.csdn.net/weixin_44406127/article/details/130031259