MySQL 安装+启动+报错的解决方案

目录

一、安装准备

1.1 下载

1.2 版本说明

二、安装步骤

2.1 解压缩

2.2 配置环境变量

2.3 配置文件

2.4 安装

2.5 启动/停止服务

三、使用说明

3.1 用户名密码登录

3.1 设置用户名密码

四、卸载步骤

4.1 卸载服务

五、安装问题

六、启动问题

6.1 提示【服务无法启动】

6.1.1 问题描述

6.1.2 解决方案


一、安装准备

1.1 下载

       1、MySQL官网地址MySQLicon-default.png?t=N7T8https://www.mysql.com/

        2、点击【DOWNLOAD】菜单。

        往下翻,点击【MySQL Community (GPL) Downloads】连接。

        选择【MySQL Community Server】选项,下载MySQL。

1.2 版本说明

        本文档编写时,使用的是8.0.26-win64的解压缩版本。

二、安装步骤

2.1 解压缩

        将压缩包解压缩到目标目录。

2.2 配置环境变量

        1、【我的电脑/此电脑】右键,点击【属性】,选择【高级系统配置】

        2、点击【环境变量】,在弹出框中,选择新建【系统变量】。

        变量名建议为:MYSQL_HOME;变量值为MySQL的解压路径;

        3、在【系统变量】中找到Path变量,并新增MYSQL的环境变量。

2.3 配置文件

        将如下内容拷贝到名为my.ini的文件中,并将其放入到解压根目录中。

        其中,较为重要的配置为:

        # 设置mysql客户端连接服务端时默认使用的端口;
        port=3306

        # 设置mysql的安装目录;
        basedir="D:\mysql\"

        # 设置mysql数据库的数据的存放目录;
        datadir="D:\mysql\data"

# MySQL Server Instance Configuration File
# ----------------------------------------------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
#
#
# Installation Instructions
# ----------------------------------------------------------------------
#
#
# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]

# 设置mysql客户端连接服务端时默认使用的端口;
port=3306
# 绑定本地IP;
bind-address = 127.0.0.1
# 客户端默认字符集编码为utf8mb4;
default-character-set=utf8mb4

[mysql]

# MySQL默认字符集编码为utf8mb4;
default-character-set=utf8mb4

# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]

# The TCP/IP Port the MySQL Server will listen on
# 设置默认端口为3306;
port=3306
# 绑定本地IP;
bind-address = 127.0.0.1

#Path to installation directory. All paths are usually resolved relative to this.
# 设置mysql的安装目录;
basedir="D:\mysql\"
#Path to the database root
# 设置mysql数据库的数据的存放目录;
datadir="D:\mysql\data"
[WinMySQLadmin]
# mysqld服务路径;
Server="D:\mysql\bin\mysqld.exe"

# The default character set that will be used when a new schema or table is
# created and no character set is defined
# 服务端默认字符集编码为utf8mb4;
default-character-set=utf8mb4

# The default storage engine that will be used when create new tables when
# 创建新表时将使用的默认存储引擎;
default-storage-engine=INNODB

# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
# 允许最大连接数;
max_connections=100

# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely changing tables. See the
# "Qcache_lowmem_prunes" status variable to check if the current value
# is high enough for your load.
# Note: In case your tables change very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
# 查询缓存大小;
query_cache_size=0

# The number of open tables for all threads. Increasing this value
# increases the number of file descriptors that mysqld requires.
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable "open-files-limit" in
# section 
[mysqld_safe]
# 表缓存大小;
table_cache=256

# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
# 临时表大小;
tmp_table_size=26M


# How many threads we should keep in a cache for reuse. When a client
# disconnects, the client's threads are put in the cache if there aren't
# more than thread_cache_size threads from before.  This greatly reduces
# the amount of thread creations needed if you have a lot of new
# connections. (Normally this doesn't give a notable performance
# improvement if you have a good thread implementation.)
# 线程数;
thread_cache_size=8

#*** MyISAM Specific options

# The maximum size of the temporary file MySQL is allowed to use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.
# If the file-size would be bigger than this, the index will be created
# through the key cache (which is slower).
myisam_max_sort_file_size=100G

# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method.  This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
myisam_sort_buffer_size=52M

# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 30% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
key_buffer_size=40M

# Size of the buffer used for doing full table scans of MyISAM tables.
# Allocated per thread, if a full scan is needed.
read_buffer_size=64K
read_rnd_buffer_size=256K

# This buffer is allocated when MySQL needs to rebuild the index in
# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE
# into an empty table. It is allocated per thread so be careful with
# large settings.
sort_buffer_size=256K


#*** INNODB Specific options ***
# INNODB的数据存放目录;
innodb_data_home_dir="D:\mysql\data\INNODB\"

# Use this option if you have a MySQL server with InnoDB support enabled
# but you do not plan to use it. This will save memory and disk space
# and speed up some things.
#skip-innodb

# Additional memory pool that is used by InnoDB to store metadata
# information.  If InnoDB requires more memory for this purpose it will
# start to allocate it from the OS.  As this is fast enough on most
# recent operating systems, you normally do not need to change this
# value. SHOW INNODB STATUS will display the current amount used.
innodb_additional_mem_pool_size=2M

# If set to 1, InnoDB will flush (fsync) the transaction logs to the
# disk at each commit, which offers full ACID behavior. If you are
# willing to compromise this safety, and you are running small
# transactions, you may set this to 0 or 2 to reduce disk I/O to the
# logs. Value 0 means that the log is only written to the log file and
# the log file flushed to disk approximately once per second. Value 2
# means the log is written to the log file at each commit, but the log
# file is only flushed to disk approximately once per second.
innodb_flush_log_at_trx_commit=1

# The size of the buffer InnoDB uses for buffering log data. As soon as
# it is full, InnoDB will have to flush it to disk. As it is flushed
# once per second anyway, it does not make sense to have it very large
# (even with long transactions).
innodb_log_buffer_size=1M

# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and
# row data. The bigger you set this the less disk I/O is needed to
# access data in tables. On a dedicated database server you may set this
# parameter up to 80% of the machine physical memory size. Do not set it
# too large, though, because competition of the physical memory may
# cause paging in the operating system.  Note that on 32bit systems you
# might be limited to 2-3.5G of user level memory per process, so do not
# set it too high.
innodb_buffer_pool_size=77M

# Size of each log file in a log group. You should set the combined size
# of log files to about 25%-100% of your buffer pool size to avoid
# unneeded buffer pool flush activity on log file overwrite. However,
# note that a larger logfile size will increase the time needed for the
# recovery process.
innodb_log_file_size=39M

# Number of threads allowed inside the InnoDB kernel. The optimal value
# depends highly on the application, hardware as well as the OS
# scheduler properties. A too high value may lead to thread thrashing.
innodb_thread_concurrency=8
 

2.4 安装

        1、使用管理员权限运行CMD(此处省略使用管理员运行CMD的方法)。

        2、使用盘符 + : 的形式,切换到目标盘符。

        3、使用CD切换到目标路径下。目标路径为解压缩目录\bin。

        4、运行mysqld install mysql --defaults-file="d:\mysql\my.ini"命令。

2.5 启动/停止服务

        运行net start mysql命令,服务启动成功。

        运行net stop mysql命令,服务停止成功。

三、使用说明

3.1 用户名密码登录

        服务初始化好后,会默认配置用户名和密码;

        A temporary password is generated for root@localhost: ******;

        输入mysql命令进行登录,-h代表IP地址,-u代表用户名,-p代表密码;

3.1 设置用户名密码

      登录后,执行命令:ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';,修改密码完成;

四、卸载步骤

4.1 卸载服务

        执行mysqld remove命令,卸载服务。

五、安装问题

暂无;

六、启动问题

6.1 提示【服务无法启动】

6.1.1 问题描述

       

        如图所示,提示服务无法启动。

6.1.2 解决方案

        根据2.3的配置,datadir="D:\mysql\data" 可知,在解压缩目录下的data目录中,存放有数据库相关文件。

        情况一

        如果是手动创建了data目录,则进入目录后,可以看到后缀名为.err的文件,打开文件可以看到启动报错信息。

        报错说明初始化data目录失败。因此需要删除data目录,由mysql自己初始化data目录,此时重新尝试即可。

        情况二

        如果使用mysqld install命令安装时,未初始化data目录,则说明安装“失败”了,启动时一定会报错。

        此时需要使用mysqld --initialize --console命令,初始化MySQL。

        初始化后,再执行mysqld install mysql --defaults-file="d:\mysql\my.ini"安装命令。

        此时,服务启动成功,可以正常使用。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/101205.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

web基础和http协议

1.DNS解析的三种方式 DNS解析: 网站都是域名:dns解析的作用是把域名解析成ip地址 迭代:从跟域名到二级域 返回用户的过程:递归---运营商--本地hosts---用户 三种方式: /etc/hosts 本地解析,速度最快&…

岩土工程安全监测无线振弦采集仪在无线组网的关键要点

岩土工程安全监测无线振弦采集仪在无线组网的关键要点 岩土工程是一种奇特而又极其重要的工程。它涉及到土地、岩石、气候等等因素,需要重视安全因素。而无线振弦采集仪作为一种常用的监测设备,可以采集岩土工程中的振动数据,从而确保工程的…

智慧安防AI视频智能分析云平台EasyCVR加密机授权小tips

视频云存储/安防监控EasyCVR视频汇聚平台基于云边端智能协同,支持海量视频的轻量化接入与汇聚、转码与处理、全网智能分发、视频集中存储等。音视频流媒体视频平台EasyCVR拓展性强,视频能力丰富,具体可实现视频监控直播、视频轮播、视频录像、…

Transformer模型 | Python实现基于LSTM与Transfomer的股票预测模型(pytorch)

文章目录 效果一览文章概述LSTM模型原理时间序列模型从RNN到LSTMLSTM预测股票模型实现结语程序设计参考资料效果一览 文章概述 基于LSTM与Transfomer的股票预测模型 股票行情是引导交易市场变化的一大重要因素,若能够掌握股票行情的走势,则对于个人和企业的投资都有巨大的帮…

【AntDesign】多环境配置和启动

环境分类,可以分为 本地环境、测试环境、生产环境等,通过对不同环境配置内容,来实现对不同环境做不同的事情。 AntDesign 项目,通过 config.xxx.ts 添加不同的后缀来区分配置文件,启动时候通过后缀启动即可。 config…

【RabbitMQ 实战】10 消息持久化和存储原理

一、持久化 1.1 持久化对象 rabbitmq的持久化分为三个部分: 交换器的持久化。队列的持久化。消息的持久化。 1.1.1 交换器持久化 交换器的持久化是通过在声明交换器时, 指定Durability参数为durable实现的。若交换器不设置持久化,在rabb…

c语言:通讯录管理系统(文件版本)

前言:在大多数高校内,都是通过设计一个通讯录管理系统来作为c语言课程设计,通过一个具体的系统设计将我们学习过的结构体和函数等知识糅合起来,可以很好的锻炼学生的编程思维,本文旨在为通讯录管理系统的设计提供思路和…

将nginx注册为Windows系统服务

文章目录 1、使用nssm小工具2、使用winsw小工具2.1、下载2.2、用法2.3、重命名2.4、创建配置文件2.4.1、xml文件2.4.2、config文件(该文件可省略) 2.5、最终文件2.6、安装与卸载 1、使用nssm小工具 该方法最简单 首先,下载nssm小工具&#…

HTML5+CSSDAY4综合案例一--热词

样式展示图&#xff1a; 代码如下&#xff1a; <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>热词…

docker 基本操作

一、docker 概述 Docker是一个开源的应用容器引擎&#xff0c;基于go语言开发并遵循了apache2.0协议开源。 Docker是在Linux容器里运行应用的开源工具&#xff0c;是一种轻量级的“虚拟机”。 Docker 的容器技术可以在一台主机上轻松为任何应用创建一个轻量级的、可移植的、自…

HomeView/主页 的实现

1. 创建数据模型 1.1 创建货币模型 CoinModel.swift import Foundation// GoinGecko API info /*URL:https://api.coingecko.com/api/v3/coins/markets?vs_currencyusd&ordermarket_cap_desc&per_page250&page1&sparklinetrue&price_change_percentage24…

机器人制作开源方案 | 齿轮传动轴偏心轮摇杆简易四足

1. 功能描述 齿轮传动轴偏心轮摇杆简易四足机器人是一种基于齿轮传动和偏心轮摇杆原理的简易四足机器人。它的设计原理通常如下&#xff1a; ① 齿轮传动&#xff1a;通过不同大小的齿轮传动&#xff0c;实现机器人四条腿的运动。通常采用轮式齿轮传动或者行星齿轮传动&#xf…

Blender:使用立方体制作动漫头像

好久没水文章 排名都掉到1w外了 ~_~ 学习一下blender&#xff0c;看能不能学习一点曲面变形的思路 一些快捷键 ctrl 空格&#xff1a;区域最大化&#xff0c;就是全屏 ctrl alt 空格&#xff1a;也是区域最大化 shift b&#xff1a;框选区域然后最大化显示该范围 shift 空…

3.springcloudalibaba gateway项目搭建

文章目录 前言一、搭建gateway项目1.1 pom配置1.2 新增配置如下 二、新增server服务2.1 pom配置2.2新增测试接口如下 三、测试验证3.1 分别启动两个服务&#xff0c;查看nacos是否注册成功3.2 测试 总结 前言 前面已经完成了springcloudalibaba项目搭建&#xff0c;接下来搭建…

AI如何帮助Salesforce从业者找工作?

在当今竞争激烈的就业市场中&#xff0c;找到满意的工作是一项艰巨的任务。成千上万的候选人竞争一个岗位&#xff0c;你需要利用一切优势从求职大军中脱颖而出。 这就是AI的用武之地&#xff0c;特别是像ChatGPT这样的人工智能工具&#xff0c;可以成为你的秘密武器。本篇文章…

【Windows】RPC调用过程实例详解

概述&#xff1a;windows 创建 RPC调用过程实例详解 参考文章&#xff1a;Remote procedure call (RPC)&#xff08;远程过程调用 (RPC)&#xff09; - Win32 apps | Microsoft Learn 文章目录 0x01、生成 UUID 和模版(IDL)文件0x02、添加 acf 文件0x03、编译 idl 文件0x04、客…

Vuex基础使用存取值+异步请求后台

目录 一、Vuex简介 1.1 定义 1.2 Vuex关键概念 1.3 使用Vuex的优势 1.4 Vuex中各个js文件的用途 1.5 Vuex各组件 1.5.1 图解 1.5.2 详解 1.6 变量传值的演变形式 二、Vuex获取值 2.1 安装 2.2 菜单栏 2.3 模块 2.4 引用 三、Vuex改变值 四、Vuex异步&请求后台…

ACK 云原生 AI 套件:云原生 AI 工程化落地最优路径

作者&#xff1a;胡玉瑜(稚柳) 前言 在过去几年中&#xff0c;人工智能技术取得了突飞猛进的发展&#xff0c;涵盖了机器学习、深度学习和神经网络等关键技术的重大突破&#xff0c;这使得人工智能在各个领域都得到广泛应用&#xff0c;对各行各业产生了深远的影响。 特别值…

计算机视觉处理的开源框架

计算机视觉是一门涉及图像和视频分析的领域&#xff0c;有许多开源的框架和库可用于构建计算机视觉应用程序。以下是一些常见的计算机视觉开源框架及其特点&#xff0c;希望对大家有所帮助。北京木奇移动技术有限公司&#xff0c;专业的软件外包开发公司&#xff0c;欢迎交流合…

地级市HVV | 未授权访问合集

在网站前后端分离盛行下&#xff0c;将大部分权限控制交给前端&#xff0c;导致js中隐藏未授权或者可绕过的前端鉴权。前后端分离的好处是提高开发效率&#xff0c;同时防止黑客更直接的对服务器造成危害&#xff0c;但权限控制的工作量全部交给前端会导致大量页面未授权或者后…