Window下mysql环境配置问题整理

  1. 云栖社区>
  2. 博客>
  3. 正文

Window下mysql环境配置问题整理

从此启程 2018-08-17 13:17:00 浏览1154
展开阅读全文

Window下mysql环境配置问题整理

参考如下链接。

无需安装解压版mysql包

创建选项配置

首次启动服务

用mysqld初始化目录

安装后设置和测试

启动服务错误信息

管理员模式打开cmd

mysqld install

net start mysql

MYSql服务正在启动

MYSql服务无法启动

解决办法

删除mysql安装主目录下的data目录下所有文件

mysqld --initialize --console

C:\WINDOWS\system32> mysqld --initizlize --console
mysqld: Can't change dir to 'D:\Program Files\mysql-8.0.12-winx64\data\' (OS errno 2 - No such file or directory)
2018-08-17T01:54:27.145772Z 0 [System] [MY-010116] [Server] D:\Program Files\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) starting as process 17876
2018-08-17T01:54:27.148482Z 0 [Warning] [MY-010091] [Server] Can't create test file D:\Program Files\mysql-8.0.12-winx64\data\DESKTOP-SET72RE.lower-test
2018-08-17T01:54:27.148571Z 0 [Warning] [MY-010091] [Server] Can't create test file D:\Program Files\mysql-8.0.12-winx64\data\DESKTOP-SET72RE.lower-test
2018-08-17T01:54:27.149798Z 0 [ERROR] [MY-010172] [Server] failed to set datadir to D:\Program Files\mysql-8.0.12-winx64\data\
2018-08-17T01:54:27.169994Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-08-17T01:54:27.172048Z 0 [System] [MY-010910] [Server] D:\Program Files\mysql-8.0.12-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.12)  MySQL Community Server - GPL.

如上述报错的话,加上user,并记录初始密码

mysqld --initialize --user=root --console

C:\WINDOWS\system32>mysqld --initialize --user=root --console
2018-08-17T03:06:51.636920Z 0 [System] [MY-013169] [Server] D:\Program Files\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) initializing of server in progress as process 7832
2018-08-17T03:06:54.218851Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: yacuOdqg/6Mn
2018-08-17T03:06:55.288246Z 0 [System] [MY-013170] [Server] D:\Program Files\mysql-8.0.12-winx64\bin\mysqld.exe (mysqld 8.0.12) initializing of server has completed

安装服务

mysqld install

C:\WINDOWS\system32>mysqld install
Service successfully installed.

启动服务

net start mysql

C:\WINDOWS\system32>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

登陆系统

如登陆不上,需要运行net stop mysql,

然后重新运行下mysqld --initialize --user=root --console

mysql -u root -p


C:\WINDOWS\system32>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.12
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>

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'fjdoe13232'; mysql执行语句一定要以;结尾。切记。

mysql>  ALTER USER 'root'@'localhost' IDENTIFIED BY 'fjdoe13232
'
; Query OK, 0 rows affected (0.11 sec)

常用命令

show databases;

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

create database 数据库;

mysql> create database ustest;
Query OK, 1 row affected (0.03 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| ustest             |
+--------------------+
5 rows in set (0.00 sec)
mysql> use ustest;
Database changed

以上是简单环境配置。

作者:从此启程/范存威

出处:http://www.cnblogs.com/fancunwei/

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接。如文章对您有用,烦请点个推荐再走,感谢! 本博客新开通打赏,鼠标移到右侧打赏浮动处,即可赏博主点零花钱,感谢您的支持!

网友评论

登录后评论
0/500
评论
从此启程
+ 关注