[Self-study MYSQL] MySQL Windows installation

MySQL Windows installation

MySQL Windows Downloads

First, we open the official website of MySQL , the URL is as follows:

https://dev.mysql.com/downloads/mysql/

On the homepage of the official website, we first select the corresponding system according to our operating system, here we choose Windows, then select the corresponding version, click Download, as follows:
insert image description here

Click Download, and then select, No thanks, to start the download:

insert image description here

MySQL unzip the file

The downloaded Mysql file is in the format of a compressed package, as follows:

insert image description here

We use a compression tool to decompress the file, and the decompression is displayed as follows:

insert image description here

MySQL modify configuration file

Create the data folder and my.ini file in the folder just unzipped. After creation, the directory is as follows:

insert image description here

We use Notepad to edit the my.ini file as follows:

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

MySQL environment variable configuration

First of all, we are on my computer, right-click properties, click advanced properties, as follows:

insert image description here

Click on the environment variable, as follows:

insert image description here

Click New, as follows:

insert image description here

Create a new user variable, the variable name is MYSQL_HOME, and the variable value is the MySQL installation address, here is D:\Soft\wamp2\mysqlas follows:
insert image description here

In the user variables, find the Path variable and edit it as follows:

insert image description here

Edit the environment variable, click New, enter %MYSQL_HOME%\bin, and click OK, as follows:
insert image description here

Finally click OK, as follows:

insert image description here

At this point, our Mysql environment variables are configured.

MySQL initialization

Open cmd to run MySQL. If you open it with a normal command line, an error will be reported, as follows:
insert image description here

At this point, we need to open the command line as an administrator, as follows:

insert image description here

To initialize MYSQL, go to the MYSQL directory first, as follows:

insert image description here

Enter the following command to initialize. At this time, a temporary password is generated, which will be used later, as follows:

insert image description here

Enter the bin directory, as follows:

insert image description here

Execute the command mysqld -install, as follows:

insert image description here

Start the mysql service as follows:

insert image description here

Run mysql, enter the command mysql -uroot -p, as follows:

insert image description here

Enter the temporary password just now, as follows:

insert image description here

Change the temporary password, here the new password is 123456, enter the command: ALERT USER root@localhost IDENTIFIED BY '123456', as follows:

insert image description here

To exit mysql, enter the command exit, as follows:

insert image description here

Re-run mysql with the new password, enter the command: mysql -uroot -p, as follows:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_41384860/article/details/129078617