Window下mysql环境配置问题整理-阿里云开发者社区

开发者社区> 数据库> 正文
登录阅读全文

Window下mysql环境配置问题整理

简介: Window下mysql环境配置问题整理 参考如下链接。 无需安装解压版mysql包 创建选项配置 首次启动服务 用mysqld初始化目录 安装后设置和测试 启动服务错误信息 管理员模式打开cmd mysqld install net start mysql MYSql服务正在启动 MY...

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/

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

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享: