Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

一、mysql下载地址:https://dev.mysql.com/downloads/mysql/

点开网址往下拉,笔者用的64位win8系统,选择了较小的zip文件。

Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

 

二、安装与登陆

解压至你要存放的目录,一般是放到C:\Program Files\ 目录下。

登陆方法是在命令提示符下输入 “cd bin的路径”(不包括双引号)回车进入bin文件夹

Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

假如是安装版,安装好以后即可执行命令”mysql -u root -p”,然后键入密码登录。

解压缩版则会遇到没有登陆密码的问题,产生”ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)”的错误提示:

Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

解决方法:

1.其实zip版解压后同样需要安装,首先配置ini文件:新建文本文件,命名为 ”my.ini”,复制粘贴分割线内的文本:

——————————————分割线——————————————

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the

# *** default location during install, and will be replaced if you

# *** upgrade to a newer version of MySQL.

 

[mysqld]

 

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

 

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

 

# These are commonly set, remove the # and set as required.

 

basedir=C:\Program Files\mysql-8.0.15

datadir=C:\Program Files\mysql-8.0.15\data

 

# port = .....

# server_id = .....

 

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

——————————————分割线——————————————

 

2.在上面的文本中找到下两个路径,改为你存放mysql 的路径,或者说是你的bin 文件夹所在的路径。改好之后保存关闭。

Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

3.重点来了!以管理员身份运行命令提示符,进入bin目录,输入”mysqld -install”,回车。收到如下提示证明笔者已经成功安装mysql。

Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

4.输入”mysqld --initialize”进行软件初始化,稍等片刻。我们在配置ini文件时设置了data文件夹的目录,data文件夹会在初始化中产生,读者可以对照看看避免安装中途出现错漏。

Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

5.如上图,输入”net start mysql”启动MySQL服务,读者打开 计算机管理>服务 即可看到该服务。

Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

6.我们已经正确安装mysql,但是到这一步我们还不知道登陆密码,笔者尝试不输入密码但收到了”ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)”错误提示。

Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

其实这一版本的mysql自动产生了临时密码,存放在刚才自动创建的data文件夹下的”你的计算机名.err”文件里,找到它并打开,temporary password 后面圈的就是临时密码,用它登陆mysql。

Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

7.输入”mysql -u root -p”回车,输入临时密码回车,看到如下提示表明你已成功登录!

Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

8.修改密码,网上的多种方法不一定都行得通,寻找一种适合你当前mysql版本的即可。笔者凭借直觉和经验输入”set password=”8888”;”居然通过了,简直无语。用新密码登陆了。

Mysql-8.0.15.zip解压缩版安装过程中MySQL服务无法启动、无登陆密码等问题的解决方案

9.读者可自行设置环境变量,将bin文件夹的路径添加到path里,方便日后使用。