1、官网下载https://dev.mysql.com/downloads/windows/installer/解压到 文件D:\database\mysql-8.0.13-winx64
2、在D:\database\mysql-8.0.13-winx64新建my-default.ini文件
[mysqld]
# 设置3308端口
port=3308
# 设置mysql的安装目录
basedir=D:\database\mysql-8.0.13-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\database\mysql-8.0.13-winx64\data
#tmpdir=D:\database\mysql-8.0.13-winx64\temp
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3308
default-character-set=utf8
3、已管理员方式打开CMD窗口,初始化数据库,这里一定要用全路径方式,
D:\database\mysql-8.0.13-winx64\bin>D:\database\mysql-8.0.13-winx64\bin\mysqld.exe --initialize-insecure
D:\database\mysql-8.0.13-winx64\bin>D:\database\mysql-8.0.13-winx64\bin\mysqld.exe --install MySQL3308 --defaults-file=D:\database\mysql-8.0.13-winx64\my-default.ini
Service successfully installed.
D:\database\mysql-8.0.13-winx64\bin>net start mysql3308
MySQL3308 服务正在启动 .
MySQL3308 服务已经启动成功。
4、初次登录数据库并修改密码:
D:\database\mysql-8.0.13-winx64\bin>mysql -h localhost -P 3308 -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.13 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
修改密码:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysql';
Query OK, 0 rows affected (0.10 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
授权其他电脑访问:
mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'mysql';
Query OK, 0 rows affected (0.09 sec)
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'mysql';
Query OK, 0 rows affected (0.04 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.07 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
最后配置 navcat连接完美启动: