Mysql安装踩坑笔记

Mysql安装踩坑笔记


安装mysql卸载安装好几遍终于成功了,记录一下踩过的坑

入坑

第一次是在官网上下载的8.0.18版本
在这里插入图片描述
在安装到最后的时候starting the server始终不成功
在这里插入图片描述
日志显示的问题

MySQL error 1042: Unable to connect to any of the specified MySQL hosts.
Failed to connect to MySQL Server 8.0.18 after 10 attempts.
Ended configuration step: Starting the server

然后看网友的建议,找到mysql80服务,右键>属性>登录,更改成本地系统账号 > 确定后,重新执行成功,但是我没有成功
传送门


然后卸载,下载低版本5.7.28
我是按照这个网友的建议卸载的 传送门
但是我的卸载过程中没有其他的多余步骤,仅仅卸载就完成了,其他的步骤我都检查了,没有多余的文件。
C:\Documents and Settings文件目录需要取消勾选显示隐藏受保护的文件,然后赋予完全控制权限
在这里插入图片描述

下载5.7版本

在这里插入图片描述

在这里插入图片描述
下载的是压缩包版本,直接解压就可以了

  • 解压后,我的文件目录
    D:\Users\Jsong\tools\Mysql\mysql-5.7.22-winx64
  • 在这个目录中新建my.ini文件,编码格式选择ANSI格式编码
    nodepad中格式>以ANSI格式编码

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=D:\\Users\\Jsong\\tools\\Mysql\\mysql-5.7.22-winx64

datadir=D:\\Users\\Jsong\\tools\\Mysql\\mysql-5.7.22-winx64\\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

注意 要使用 \\
basedir=D:\\Users\\Jsong\\tools\\Mysql\\mysql-5.7.22-winx64
datadir=D:\\Users\\Jsong\\tools\\Mysql\\mysql-5.7.22-winx64\\data

否则Mysql初始化的时候会有这个问题

mysqld: Can't create/write to file 'D:\Users\Jsong      ools\Mysql\mysql-5.7.22-winx64\data\is_writable' (Errcode: 2 - No such file or directory)
2019-11-09T02:16:53.861687Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-11-09T02:16:53.862353Z 0 [ERROR] Can't find error-message file 'D:\Users\Jsong     ools\Mysql\mysql-5.7.22-winx64\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2019-11-09T02:16:53.864165Z 0 [ERROR] --initialize specified but the data directory exists and is not writable. Aborting.
2019-11-09T02:16:53.864376Z 0 [ERROR] Aborting

  • 安装
    在 D:\Users\Jsong\tools\Mysql\mysql-5.7.22-winx64\bin目录下执行

mysqld install

又出现了新问题
程序无法正常启动(0xc000007b)
下载driectx
参考这篇文章

  • 初始化数据库
    会在D:\Users\Jsong\tools\Mysql\mysql-5.7.22-winx64\data文件夹下生成数据库文件

mysqld --initialize

  • 启服务

net start mysql

  • 连接数据库

mysql -u{username} -p{password}

  • 查看root用户密码
    D:\Users\Jsong\tools\Mysql\mysql-5.7.22-winx64\data\xxx.err
    文件中 写有秘密 root@localhost: 7lKyqqMt!0TU
2019-11-09T02:19:16.178984Z 1 [Note] A temporary password is generated for root@localhost: 7lKyqqMt!0TU
  • 登录

mysql -uroot -p7lKyqqMt!0TU

D:\Users\Jsong\tools\Mysql\mysql-5.7.22-winx64\bin>mysql -uroot -p7lKyqqMt!0TU
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 15
Server version: 5.7.22

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.
  • 修改密码

alter user root@localhost identified by ‘1’;

mysql> alter user root@localhost identified by '1';
Query OK, 0 rows affected (0.00 sec)
  • 退出

exit;

  • 停止服务

net stop mysql

发布了83 篇原创文章 · 获赞 21 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/JsongNeu/article/details/102985241
今日推荐