Install MySQL under Windows, Xiaobai style graphic tutorial
1. Enter MySQL official website
1.1 Click DOWNLOADS
1.2 to slide down, find and MySQL Community (GPL) Downloads »
click to enter
1.3 and click MySQL Community Server
1.4 to select the corresponding version, click Download
to download, here we choose the first one to download online, and the second one is not necessary.
After the download is complete, unzip it (it is recommended to put it in a disk other than the system disk, create a MySQL folder for storage, such as mine D:\MySQL\mysql-8.0.21-winx64
)
2. Enter the file directory and create a new my.ini file
Add the following, remember to change the settings mysql的安装目录
with mysql数据库的数据的存放目录
which is above us that directory (according to their own directory), remember, the second directly behind plus installation directory \ data, to a data storage directory.
The content of my.ini file:
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\MySQL\mysql-8.0.21-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\MySQL\mysql-8.0.21-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
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8
Finally save and exit
3. Configure environment variables
3.1 Click the win button, find 此电脑
, select 属性
3.2, click 高级系统设置
3.3, click 环境变量
3.4 in 系统变量
, find Path
, click 编辑
3.5, click 新建
, fill in 安装目录
, click 确定
3.6, and then confirm all.
4. Initial configuration
4.1 Click win键
and find 命令提示符
> 以管理员身份运行
4.2 Initialize, this command will not automatically set the password (we will set it ourselves later)
mysqld --initialize-insecure --user=mysql
mysqld -install
If it appears: Service successfully installed. The configuration is successful
5. Start mysql
net start mysql
Look at the effect of the above three lines of code:
6. Enter the database
mysql -u root -p
Note that we did not set a password just now, so just press Enter
7. Set a password (don’t forget the end;)
alter user user() identified by "新密码";
8. Verification:
Enter to quit
exit the database, then enter it again net start mysql
, enter the password you just set to verify whether the change is successful
, the effect of the above code running:
9. Exit the database
quit
10. Close mysql
net stop mysql
This completes the whole process of installing MySQL under Windows.