现在离线安装包:
- 登录官网准备下载
https://dev.mysql.com/downloads/mysql/
2,开始下载
解压安装包:
开始解压:
解压完成:
新建init文件:
在解压目录下创建my.ini文件
[Client] port = 3306 [mysqld] #设置3306端口 port = 3306 # 设置mysql的安装目录 basedir=D:WorkSpaceDevEnvDatabasesMySQLmysql8 # 设置mysql数据库的数据的存放目录 datadir=D:WorkSpaceDevEnvDatabasesMySQLmysql8data # 允许最大连接数 max_connections=20 # 服务端使用的字符集默认为8比特编码的latin1字符集 character-set-server=utf8 # 创建新表时将使用的默认存储引擎 default-storage-engine=INNODB [mysql] # 设置mysql客户端默认字符集 default-character-set=utf8 |
初始化MySQL:
使用管理员运行dos窗口:
使用命令进行初始化MySQL:
C:Usersadmin>d: D:>cd D:WorkSpaceDevEnvDatabasesMySQLmysql8in D:WorkSpaceDevEnvDatabasesMySQLmysql8in>mysqld --initialize --user=mysql --console 2020-06-01T12:56:18.263432Z 0 [System] [MY-013169] [Server] D:WorkSpaceDevEnvDatabasesMySQLmysql8inmysqld.exe (mysqld 8.0.20) initializing of server in progress as process 35440 2020-06-01T12:56:18.278456Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. 2020-06-01T12:56:18.293667Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2020-06-01T12:56:18.822197Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2020-06-01T12:56:20.349728Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: *9OjstMrX.Qp D:WorkSpaceDevEnvDatabasesMySQLmysql8in> |
初始化完成如下:
命令安装MySQL:
D:WorkSpaceDevEnvDatabasesMySQLmysql8in>mysqld --install mysql Service successfully installed. D:WorkSpaceDevEnvDatabasesMySQLmysql8in> |
启动MySQL服务:
D:WorkSpaceDevEnvDatabasesMySQLmysql8in>net start mysql mysql 服务正在启动 . mysql 服务已经启动成功。 D:WorkSpaceDevEnvDatabasesMySQLmysql8in> |
登录MySQL:
D:WorkSpaceDevEnvDatabasesMySQLmysql8in>mysql -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.20 Copyright (c) 2000, 2020, 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> |
修改MySQL8的密码:
注意:到了MySQL8对于修改密码拥有了严格的语法限制:
mysql> alter user'root'@'localhost' identified with mysql_native_password by 'root' ; Query OK, 0 rows affected (0.02 sec) mysql> Flush privileges; Query OK, 0 rows affected (0.04 sec) mysql> exit; Bye D:WorkSpaceDevEnvDatabasesMySQLmysql8in> |
使用新密码登录MySQL:
D:WorkSpaceDevEnvDatabasesMySQLmysql8in>mysql -u root -p Enter password: **** Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 9 Server version: 8.0.20 MySQL Community Server - GPL Copyright (c) 2000, 2020, 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> exit; Bye |
配置环境变量
为了后续方便,所以配置MySQL Path变量