Download and installation of mysql under windows

1 download

  • Official website address
    https://www.mysql.com/
  • click to download
    insert image description here
  • community download
    insert image description here
  • community service
    insert image description here
  • Select version to download
    insert image description here

2 Create a new data folder and my.ini in the installation directory

insert image description here

  • The content of my.ini is as follows
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8

[mysqld]
#设置端口
port=3306
#设置mysql根目录
basedir=D:\code_soft\mysql\mysql-8.0.34-winx64
#设置数据库的数据存放目录
datadir=D:\code_soft\mysql\mysql-8.0.34-winx64\data
#设置最大连接数
max_connections=200
#设置mysql服务端字符集,默认为latin1
character-set-server=UTF8MB4
#设置默认存储引擎
default-storage-engine=INNODB
#设置密码永不过期
default_password_lifetime=0
#设置 server接受的数据包大小
max_allowed_packet=16M
#慢查询日志1开启2关闭
slow_query_log=1
#慢查询时间限制为2秒
long_query_time=2

3 installation

  • Enter the bin directory as an administrator
    cd D:\code_soft\mysql\mysql-8.0.34-winx64\bin
  • initialization
mysqld --initialize-insecure --user=mysql
mysqld --install MySQL
net start mysql
# 直接登录无密码 
mysql -uroot -p

insert image description here

  • Problems that may arise
    insert image description here
  • Just add the corresponding file under C:\Windows\System32
    insert image description here

4Set password and remote connection

*The first time you log in to the MySQL database, you need to reset the password to continue the subsequent database operations

  • change Password
alter user 'root'@'localhost' identified by '123456';
  • Allow remote connections
use mysql;
update user set host = '%' where user = 'root';
flush privileges;
  • Set the encoding format of the password to mysql_native_password
alter user 'root'@'%' identified with mysql_native_password by '123456';
  • set password level
set global validate_password.policy = 0;
  • Set password length
set global validate_password.length = 4

5 Configure environment variables

  • MYSQL_HOME
    insert image description here
  • PATH
    insert image description here

6 navicate connection is successful

insert image description here

Guess you like

Origin blog.csdn.net/weixin_43684214/article/details/132077562