win 安装mysql

参考

MySQL 8.0 for Windows v8.0.33 官方免费绿色正式版 64位

 

DbVisualizer Pro(跨平台数据库工具) v14.0

 

在bin目录同级下创建一个文件,命名为my.ini

D:\mysql_winx64\mysql-8.0.33-winx64\   下创建data目录

编辑my.ini文件,文件内容如下:

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录 ---这里输入你安装的文件路径----
basedir=D:\mysql_winx64\mysql-8.0.33-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\mysql_winx64\mysql-8.0.33-winx64\data
# 允许最大连接数
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=3306
default-character-set=utf8

管理员身份运行cmd

C:\>D:

D:\>cd \mysql_winx64\mysql-8.0.33-winx64\bin

D:\mysql_winx64\mysql-8.0.33-winx64\bin>

安装  

mysqld --initialize --console
D:\mysql_winx64\mysql-8.0.33-winx64\bin>mysqld --initialize --console
2023-06-22T05:45:15.808308Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2023-06-22T05:45:15.808348Z 0 [System] [MY-013169] [Server] D:\mysql_winx64\mysql-8.0.33-winx64\bin\mysqld.exe (mysqld 8.0.33) initializing of server in progress as process 8608
2023-06-22T05:45:15.811684Z 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.
2023-06-22T05:45:15.862957Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-06-22T05:45:16.512572Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-06-22T05:45:18.056576Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Ijfh4xgzdw?U
D:\mysql_winx64\mysql-8.0.33-winx64\bin>mysqld --install mysql
Service successfully installed.

 启动mysql

登录

D:\mysql_winx64\mysql-8.0.33-winx64\bin>mysql -uroot -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.33

Copyright (c) 2000, 2023, 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 '123mysql';

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123mysql';
Query OK, 0 rows affected (0.01 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql>

 

posted on 2023-06-22 14:06  寒星12345678999  阅读(9)  评论(0编辑  收藏  举报