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:
Click Download, and then select, No thanks, to start the download:
MySQL unzip the file
The downloaded Mysql file is in the format of a compressed package, as follows:
We use a compression tool to decompress the file, and the decompression is displayed as follows:
MySQL modify configuration file
Create the data folder and my.ini file in the folder just unzipped. After creation, the directory is as follows:
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:
Click on the environment variable, as follows:
Click New, as follows:
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\mysql
as follows:
In the user variables, find the Path variable and edit it as follows:
Edit the environment variable, click New, enter %MYSQL_HOME%\bin, and click OK, as follows:
Finally click OK, as follows:
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:
At this point, we need to open the command line as an administrator, as follows:
To initialize MYSQL, go to the MYSQL directory first, as follows:
Enter the following command to initialize. At this time, a temporary password is generated, which will be used later, as follows:
Enter the bin directory, as follows:
Execute the command mysqld -install, as follows:
Start the mysql service as follows:
Run mysql, enter the command mysql -uroot -p, as follows:
Enter the temporary password just now, as follows:
Change the temporary password, here the new password is 123456, enter the command: ALERT USER root@localhost IDENTIFIED BY '123456', as follows:
To exit mysql, enter the command exit, as follows:
Re-run mysql with the new password, enter the command: mysql -uroot -p, as follows: