再一次安装mysql mysql-5.7.18-win32

官网下载,然后解压:C:\mysql-5.7.18-win32
添加环境变量path—C:\mysql-5.7.18-win32\bin
系统环境不符合要求,有弹出文件缺失,要复制msvcr120.dll和mscvp120.dll到system32目录下,可能是安装office2016引起的不良反应。

–直接启动,无法完成
C:\mysql-5.7.18-win32\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务无法启动。

服务没有报告任何错误。

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

–进行初始化
C:\mysql-5.7.18-win32\bin>mysqld --initialize-insecure --user=mysql
–上面的操作会创建data目录

–仍然无法登录,因为还没有启动
C:\mysql-5.7.18-win32\bin>mysql -u root -p
Enter password:
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)
–再一次安装服务
C:\mysql-5.7.18-win32\bin>mysqld -install
The service already exists!
The current server installed: C:\mysql-5.7.18-win32\bin\mysqld MySQL
–再一次启动服务
C:\mysql-5.7.18-win32\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

–登录服务器,此时root没有密码,直接回车
C:\mysql-5.7.18-win32\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18 MySQL Community Server (GPL)

Copyright © 2000, 2017, 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
–设置root密码
C:\mysql-5.7.18-win32\bin>mysqladmin -u root -p password
Enter password: ******** --这里,一定是没有密码的,所以要直接回车
mysqladmin: connect to server at ‘localhost’ failed
error: ‘Access denied for user ‘root’@‘localhost’ (using password: YES)’

C:\mysql-5.7.18-win32\bin>mysqladmin -u root -p password
Enter password: --回车
New password: ******** --新密码
Confirm new password: ******** --重复新密码 **********
Warning: Since password will be sent to server in plain text, use ssl connection
to ensure password safety.
–重启服务
C:\mysql-5.7.18-win32\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
C:\mysql-5.7.18-win32\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
–重新登录,密码要输入正确
C:\mysql-5.7.18-win32\bin>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18 MySQL Community Server (GPL)

Copyright © 2000, 2017, 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.00 sec)

mysql>

你可能感兴趣的:(数据库)