Mysql offline installation and configuration on Windows


The server is Windows Server 2012, the internal network server, cannot connect to the external network, so the installation of Mysql can only be

The way to install offline.

First go to the official website of Mysql to download the offline compressed package

Select the appropriate version according to your needs, and click the download button of the ZIP Archive version.

It is recommended not to choose a mysql version that is too new.

Then choose to start the download directly and wait for the download to complete.


Follow the public
account Domineering
programmers Get programming-related e-books, tutorial pushes and free downloads.


Then copy the zip package to a directory on the server and decompress it.

The directory after decompression is probably like this.

Configure environment variables

Configure environment variables-system variables, new


Then the value is the directory after you unzipped

Then find the Path variable and change


Append to the end.

Configure Mysql

Then in the unzipped directory, create a new configuration file my.ini

You can create a new my.txt first, and then change the suffix to ini after editing. The content of the configuration file is as follows

Remember that the format of the file saved here must be ANSI, not UTF-8

[mysqld]# 设置3306端口port=3306# 设置mysql的安装目录basedir=F:\mysql-8.0.17-winx64# 设置mysql数据库的数据的存放目录datadir=F:\mysql-8.0.17-winx64\data# 允许最大连接数max_connections=500# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统max_connect_errors=10# 服务端使用的字符集默认为UTF8character-set-server=utf8# 创建新表时将使用的默认存储引擎default-storage-engine=INNODB[mysql]# 设置mysql客户端默认字符集default-character-set=utf8[client]# 设置mysql客户端连接服务端时默认使用的端口port=3306default-character-set=utf8

Need to modify the installation directory and data storage directory according to your own situation

The installation directory here is the decompression directory, and the data storage directory is the data directory under the decompression directory

Remember that this directory should not be created manually, it will be created automatically by executing the following command, and a bunch of files will be generated

Then open cmd in the bin directory

mysqld --initialize-insecure

There will be no output from this command, but a data directory will be generated under the data storage directory configured above.

install service

Then continue in the bin directory

mysqld -install

Service installed successfully

Start service

net start mysql

Then log in to Mysql

mysql -u root -p

Then press Enter and you will be prompted to enter the password. If there is no password at this time, press Enter directly.

Then perform the operation to change the password.

You can change the native_password password of the ROOT user

Change root user password

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY'root';

The mysql_native_passwd password is changed, which is equivalent to changing the user's original password and
granting all permissions


Refresh permissions

Flush privileges;

Enable remote access

update user set host='%' where user='root';
Flush privileges;

Finally, the root account of the user table in the mysql database is changed. The host is %, that is, all can be accessed remotely, and the password is also in this table.