一、下载安装包
MySQL :: Download MySQL Community Serverhttps://dev.mysql.com/downloads/mysql/
二、解压安装包,新建my.ini
[mysql]
default-character-set=utf8
[mysqld]
port=3306
default_authentication_plugin=mysql_native_password
basedir=D:/mysql8.0.30/
datadir=D:/mysql8.0.30/data/
character-set-server=utf8
default-storage-engine=InnoDB
collation-server=utf8_unicode_ci
init_connect='SET NAMES utf8'
innodb_buffer_pool_size=512M
innodb_lock_wait_timeout=31536000
innodb_log_buffer_size=8M
innodb_log_file_size=16M
join_buffer_size=200M
key_buffer_size=400M
log-error="D:/mysql8.0.30/data"
log_error_verbosity=1
max_allowed_packet=50000M
max_connections=1000
max_heap_table_size=6400M
myisam_max_sort_file_size=64G
myisam_sort_buffer_size=32M
read_buffer_size=4kb
read_rnd_buffer_size=4000M
server_id=1
skip-external-locking=on
sort_buffer_size=256kb
table_open_cache=256
thread_cache_size=16
tmp_table_size=64M
wait_timeout=31536000
interactive_timeout=31536000
sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
group_concat_max_len=1024000
[client]
port=3306
default-character-set=utf8
三、进入bin 目录 初始化数据库
D:\mysql8.0.30\bin>mysqld --initialize --console
2022-10-10T05:16:41.423061Z 0 [System] [MY-013169] [Server] D:\mysql8.0.30\bin\mysqld.exe (mysqld 8.0.30) initializing of server in progress as process 14536
2022-10-10T05:16:41.615195Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-10-10T05:16:49.343213Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-10-10T05:16:52.944810Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ,bIN3,wDHs/o
D:\mysql8.0.30\bin>
四、用管理员运行cmd 安装服务
D:\mysql8.0.30\bin>mysqld --install mysql8.0.30
Service successfully installed.
D:\mysql8.0.30\bin>
五、启动数据库
D:\mysql8.0.30\bin>net start mysql8.0.30
mysql8.0.30 服务正在启动 ...
mysql8.0.30 服务已经启动成功。
六、连接数据库
D:\mysql8.0.30\bin>mysql -uroot -p,bIN3,wDHs/o
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.30
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
七、修改数据库密码
ALTER USER 'root'@'localhost' IDENTIFIED BY "xxxx";
八、创建新用户
mysql> create user 'cfl'@'%' identified by '123456';
Query OK, 0 rows affected (0.21 sec)
mysql>
九、授权用户, archivessiveTwo 为数据库名称,可以是*.* 就是对所有数据库进行授权
mysql> grant all privileges on archivessiveTwo.* to 'cfl'@'%' with grant option;
Query OK, 0 rows affected (0.10 sec)
十、刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.07 sec)