1)解压zip包mysql-8.0.16-winx64,在mysql-8.0.16-winx64下建my.ini
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=E:\mysql-8.0.16-winx64
# 设置mysql数据库的数据的存放目录
datadir=E:\mysql-8.0.16-winx64\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
2)使用管理员操作cmd
cd E:\mysql-8.0.16-winx64\bin
3)mysqld --initialize --user=mysql --console
4)mysqld --install
5)net start mysql
6)mysql -uroot -p
lth)#PnHd2f-
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;
C:\mysql-8.0.16-winx64\bin>mysqld --initialize --user=mysql --console
2021-02-22T08:14:26.030578Z 0 [System] [MY-013169] [Server] C:\mysql-8.0.16-winx
64\bin\mysqld.exe (mysqld 8.0.16) initializing of server in progress as process
2032
2021-02-22T08:14:33.690191Z 5 [Note] [MY-010454] [Server] A temporary password i
s generated for root@localhost: lth)#PnHd2f-
2021-02-22T08:14:34.454593Z 0 [System] [MY-013170] [Server] C:\mysql-8.0.16-winx
64\bin\mysqld.exe (mysqld 8.0.16) initializing of server has completed
C:\mysql-8.0.16-winx64\bin>mysqld --install
Service successfully installed.
mysql -uroot -p
lth)#PnHd2f-
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;
新建用户 并把数据库操作权限赋给它
create user 'aaa'@'192.168.%' identified by '123456' PASSWORD EXPIRE NEVER;
ALTER USER 'aaa'@'192.168.%' IDENTIFIED WITH mysql_native_password BY 'bbbb'; 只对某个网段有操作
GRANT ALL ON aadatabase.* TO 'aaa'@'192.168.%';
flush privileges;