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

news2024/9/28 17:27:16

目录

一、安装准备

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.coloradmin.cn/o/1073569.html

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

相关文章

VS Code如何给Python配置虚拟环境

在python中,可以通过Conda创建虚拟环境,与PyCharm联合使用。今天,在VS Code 上创建虚拟环境,在虚拟环境中安装第三方库。 首先,打开一个新的空文件夹(CRM)。 然后,新建一个python文件…

自动导入时,Element-plus Message Box组件样式丢失

问题描述 当使用Element-plus ElMessageBox弹出时,样式丢失。具体表现为弹窗显示在左上角,背景页面均为透明。 解决方案 在main.ts中,引入message-box.scss,具体代码为: import element-plus/theme-chalk/src/mes…

神经网络(MLP多层感知器)

分类 神经网络可以分为多种不同的类型,下面列举一些常见的神经网络类型: 前馈神经网络(Feedforward Neural Network):前馈神经网络是最基本的神经网络类型,也是深度学习中最常见的神经网络类型。它由若干个…

算法深度解析:视频实时美颜SDK背后的技术奥秘

美颜技术已经成为了当今数字时代的一种流行趋势。无论是社交媒体上的自拍照片还是在线视频直播,人们都渴望在镜头前呈现出最佳的自己。为了满足这一需求,视频实时美颜SDK应运而生,它们背后蕴含着复杂的算法和技术,今天就让我们一同…

网安周报|Mixin Network 云服务商数据库遭到攻击,涉案金额约 2 亿美元

1、Mixin Network 云服务商数据库遭到攻击,涉案金额约 2 亿美元 Mixin Network是一个开源的数字资产点对点交易网络,今天在Twitter上宣布,由于该平台遭受了黑客攻击,存款和取款立即暂停。据报道,该攻击的目标是Mixin云…

Super-jacoco应用统计代码覆盖率及问题处理

一、原文地址 滴滴开源Super-jacoco:java代码覆盖率收集平台 - 掘金 二、背景 我要使用Super-jacoco,对手工测试,进行代码覆盖率的统计。 为什么使用Super-jacoco,而不是直接使用jacoco,因为Super-jacoco解决了增量…

13 英寸 MacBook Air 与 MacBook Pro 评比

Apple 目前销售两款笔记本电脑系列:MacBook Pro(提供13英寸 M2、14英寸 M1 Pro/Max和16 英寸 M1 Pro/Max型号)和 MacBook Air(提供13.3 英寸 M1或13.6 英寸 M2型号)。该系列中包含一系列规格相似的 13 英寸 Mac 笔记本…

Java中使用C代码

开发工具: Intellij Idea 与 Visual Studio使用方式: Visual生成.dll文件(Windows .dll文件, Linux .so文件); jdk添加.dll文件, Idea java 采用native方式注册与使用c代码.1. 如下图, 打开idea,新建class Demo, 通过命令行生成Demo.h public class Demo {public native voi…

使用kubectl连接远程Kubernetes(k8s)集群

使用kubectl连接远程Kubernetes集群 环境准备下载kubectl下载地址 安装kubectl并处理配置文件Windows的安装配置安装kubectl拉取配置文件安装kubectl拉取配置文件kubectl命令自动补全 Linux的安装配置安装kubectl拉取配置文件kubectl命令自动补全 环境准备 你需要准备一个Kube…

Centos7使用nginx搭建rtmp流媒体服务器

为什么写这篇文章 2023年10月份,公司系统中有个需求,需要使用摄像头记录工程师在维修设备时的工作状态,找到了一家做执法记录仪的厂商,通过厂商发过来的文档了解到该执法记录仪支持通过rtmp协议推流至服务器,第一次接…

redis 管道 pipeline

原生批量命令 VS pipeline 原生批量命令是原子性(mset、mget),pipeline是非原子性原生批量命令一次只能执行一种命令,pipeline支持批量执行不同的命令原生批命令是服务端实现, pipeline 需要服务端与客户端共同完成 …

锁降级 ReentrantReadWriteLock

锁降级 ReentrantReadWriteLock 所谓降级,可以通过一个例子理解,一般都是写的权限大,读的权限小,从写到读自然是降级,这是通俗的理解。 锁降级:同一个线程先获取写锁,在写锁未释放的情况下&…

零编程开发数据可视化大屏须知

随着综合分析多业务系统数据能力的提升,以及将复杂数据可视化效果的加强,数据可视化大屏越来越受到各行各业的喜爱,经常可以在各类博览中心、会议中心、监控中心场合中看到它们的身影。这些数据可视化大屏或用于展示企业经营实力,…

指定加拿大|环境科学老师获阿尔伯塔大学邀请函

U老师入选了省公派出国项目,其指定加拿大,并要求专业为世界排名领先,或者是能填补国内科研和技术空白的短板学科。我们利用广泛资源,开展精准申请,先后得到多所大学反馈,并获得4所大学的邀请函,…

【pytorch】多GPU同时训练模型

文章目录 1. 基本原理单机多卡训练教程——DP模式 2. Pytorch进行单机多卡训练步骤1. 指定GPU2. 更改模型训练方式3. 更改权重保存方式 摘要:多GPU同时训练,能够解决单张GPU显存不足问题,同时加快模型训练。 1. 基本原理 单机多卡训练教程—…

AWS AD Connector 的网络配置

配置 AWS 的 AD Connector 通常遇到的都是些网络问题,且 AD Connector 本身屏蔽了一些网络细节,使得查找root cause往往有点困难,本文就把 AD Connector 网络问题梳理一下。 首先,需要搞清楚的是:AD Connector 是 Microsoft Active Directory 的一种代理,IAM可以通过它联…

如何用CRM客户管理系统有效管理客户

客户是企业重要的收益来源和可持续发展的基础,客户转化和留存率时刻影响着企业的发展。企业要实现更多客户转化,就要科学有效地管理客户。下面说说CRM客户管理系统如何有效管理客户? 一、多渠道获取客户 CRM系统能够帮助企业进行多渠道沟通…

充气膜结构的应用领域

由于充气膜结构具有丰富多彩的造型,优异的建筑特性、结构特性和适宜的经济性等其他传统建筑无法比拟的优势,因此备受人们青睐,被应用于工业、民用、军事等许多领域中,具有广阔的应用前景。 充气膜结构的主要应用领域包括&#xff…

Java另一棵树的子树

目录 1.题目描述 2.题解 思路分析 具体实现 完整代码 1.题目描述 给你两棵二叉树 root 和 subRoot 。检验 root 中是否包含和 subRoot 具有相同结构和节点值的子树。如果存在,返回 true ;否则,返回 false 。 二叉树 tree 的一棵子树包括…

笔记本外接显示器,edge浏览器播放视频黑屏

记录一下解决的办法 笔记本:联想拯救者R720 外接显示器后,用Edge在B站看视频有时会黑屏 网上搜了一圈,可能是因为笔记本连到了集显导致的 查看了一下显示器,确实连的是集显,找了联想客服,说这个是默认的&a…