windows上安装mysql数据库

  1. 解压到相应目录

  2. windows系统下以管理员身份调出cmd黑窗口,在命令行模式下进入刚刚MYSQL的安装目录中的子目录bin

执行mysqld -install MySql57 (新建的服务名为MySql57,以免和已有mysql服务冲突)
3. 配置MySQL, 执行mysqld --initialize
4. 添加my.ini, 并修改相关配置(注意端口号不要冲突)

  1. 启动mysql: net start MySql57
  2. 启动数据库
    在data目录中将有.err 文件,找到

后边的就是默认生成的密码
a) mysql -u root -P 3308 -p
b) 更新密码set password for root@localhost=password(‘xxxxxx’);

D:\mysql-5.7.27-winx64\bin>mysql -V
mysql  Ver 14.14 Distrib 5.7.27, for Win64 (x86_64)

D:\mysql-5.7.27-winx64\bin>mysql -V
mysql  Ver 14.14 Distrib 5.7.27, for Win64 (x86_64)

D:\mysql-5.7.27-winx64\bin>mysqld --remove mysql
Service successfully removed.

D:\mysql-5.7.27-winx64\bin>mysqld --initialize

D:\mysql-5.7.27-winx64\bin>mysqld -install mysql
Service successfully installed.

D:\mysql-5.7.27-winx64\bin>net start mysql
mysql 服务正在启动 .
mysql 服务已经启动成功。


D:\mysql-5.7.27-winx64\bin>mysql -uroot -pqspXbA92T4/h
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 2
Server version: 5.7.27
Copyright (c) 2000, 2019, 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> set password for root@localhost=password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)

    -> use mysql;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'privilegs;
flush privilegs
use mysql' at line 1
mysql> update user set host = '%' where user ='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql>

第二次安装还是报错
原来是端口冲突 不指定3306就不报错了

Microsoft Windows [版本 10.0.16299.64]
(c) 2017 Microsoft Corporation。保留所有权利。

C:\Users\Administrator>cd D:\mysql-5.7.27-winx64\bin

C:\Users\Administrator>d:

D:\mysql-5.7.27-winx64\bin>mysqld -install
The service already exists!
The current server installed: D:\mysql-5.7.27-winx64\bin\mysqld mysql

D:\mysql-5.7.27-winx64\bin>mysqld  --initialize
2019-10-15T08:24:49.708502Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-10-15T08:24:49.710044Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2019-10-15T08:24:49.710544Z 0 [ERROR] Aborting


D:\mysql-5.7.27-winx64\bin>mysqld --remove mysql
Service successfully removed.

D:\mysql-5.7.27-winx64\bin>mysqld --initialize

D:\mysql-5.7.27-winx64\bin>mysqld -install mysql
Service successfully installed.

D:\mysql-5.7.27-winx64\bin>mysql -uroot -pqspXbA92T4/h
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

D:\mysql-5.7.27-winx64\bin>net start mysql
mysql 服务正在启动 .
mysql 服务无法启动。

服务没有报告任何错误。

请键入 NET HELPMSG 3534 以获得更多的帮助。


D:\mysql-5.7.27-winx64\bin>net start mysql
mysql 服务正在启动 .
mysql 服务无法启动。

服务没有报告任何错误。

请键入 NET HELPMSG 3534 以获得更多的帮助。


D:\mysql-5.7.27-winx64\bin>mysqld --remove mysql
Service successfully removed.

D:\mysql-5.7.27-winx64\bin>mysqld  --initialize
2019-10-15T08:35:31.215034Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-10-15T08:35:31.216464Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2019-10-15T08:35:31.216942Z 0 [ERROR] Aborting


D:\mysql-5.7.27-winx64\bin>mysqld -install
Service successfully installed.

D:\mysql-5.7.27-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。


D:\mysql-5.7.27-winx64\bin>mysql -uroot -psuHwVmqJf5=i
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

D:\mysql-5.7.27-winx64\bin>mysql -uroot -psuHwVmqJf5=i
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

D:\mysql-5.7.27-winx64\bin>mysql -uroot -psuHwVm
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

D:\mysql-5.7.27-winx64\bin>mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

D:\mysql-5.7.27-winx64\bin>mysql -uroot -P3309 -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

D:\mysql-5.7.27-winx64\bin>mysql -uroot -P3309 -psuHwVmqJf5=i
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 3
Server version: 5.7.27

Copyright (c) 2000, 2019, 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> update user set host = '%' where user ='root';
ERROR 1046 (3D000): No database selected
mysql> set password for root@localhost=password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit
Bye

D:\mysql-5.7.27-winx64\bin>mysql -uroot -P3309 -proot
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 4
Server version: 5.7.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> update user set host = '%' where user ='root';
ERROR 1046 (3D000): No database selected
mysql> use mysql;
Database changed
mysql> update user set host = '%' where user ='root';
Query OK, 1 row affected (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> set password for root@localhost=password('root');
ERROR 1133 (42000): Can't find any matching row in the user table
mysql>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值