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.rhkb.cn/news/157272.html

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

相关文章

Docker部署gitlab_ce(避坑版---社区版)

1 下载docker 2 下载gitlab镜像 3 运行 4 进入容器内部修改 5 在浏览器里访问 6 修改root密码(如果忘记请修改) 1 下载docker # 安装依赖 yum install -y yum-utils device-mapper-persistent-data lvm2# 设置yum源 yum-config-manager --add-repo https…

国内ITSM发展的趋势

多年来,随着客户业务需求、工作文化、技术创新的不断变化以及新的IT环境的出现, IT支持也出现了新的变化,由单一的IT帮助台( IT help desk)逐渐转变为了综合性的IT服务台( IT service desk)&…

Vulnhub系列靶机---Raven: 2

文章目录 信息收集主机发现端口扫描目录扫描用户枚举 漏洞发现漏洞利用UDF脚本MySQL提权SUID提权 靶机文档:Raven: 2 下载地址:Download (Mirror) 信息收集 靶机MAC地址:00:0C:29:15:7F:17 主机发现 sudo nmap -sn 192.168.8.0/24sudo arp…

大数据NoSQL数据库HBase集群部署

目录 1. 简介 2. 安装 1. HBase依赖Zookeeper、JDK、Hadoop(HDFS),请确保已经完成前面 2. 【node1执行】下载HBase安装包 3. 【node1执行】,修改配置文件,修改conf/hbase-env.sh文件 4. 【node1执行】&#xf…

Pymol做B因子图

分子动力学模拟结束后,获得蛋白的平均结构, 比如获得的平均结构为WT-average.pdb 然后将平均结构导入到Pymol 中,可以得到B因子图。 gmx rmsf -f md_0_100_noPBC.xtc -s md_0_100.tpr -o rmsf-per-residue.xvg -ox average.pdb -oq bfactors…

【TES720D】基于复旦微的FMQL20S400全国产化ARM核心模块

TES720D是一款基于上海复旦微电子FMQL20S400的全国产化核心模块。该核心模块将复旦微的FMQL20S400(兼容FMQL10S400)的最小系统集成在了一个50*70mm的核心板上,可以作为一个核心模块,进行功能性扩展,特别是用在控制领域…

2、vscode c++ 项目配置调试及运行

文章目录 1、项目布局2、多项目管理2.1 先是一个总的CMakeLists.txt2.2 每个项目2.3 多版本OPENCV 3、调试和运行 接上一篇文章,vscode和cmake的c环境配置好以后,我们要写项目,再写对应的CMakeLists.txt 1、项目布局 . ├── bin ├── bu…

华为云Stack的学习(九)

十、华为云Stack灾备服务介绍 1.云硬盘备份VBS 云硬盘备份服务(VBS,Volume Backup Service)可为云硬盘(EVS,Elastic Volume Service)创建备份,利用备份数据恢复云硬盘,最大限度保障…

『PyQt5-Qt Designer篇』| 13 Qt Designer中如何给工具添加菜单和工具栏?

13 Qt Designer中如何给工具添加菜单和工具栏? 1 创建默认窗口2 添加菜单栏3 查看和调用1 创建默认窗口 当新创建一个窗口的时候,默认会显示有:菜单栏和状态栏,如下: 可以在菜单栏上右键-移除菜单栏: 可以在菜单栏上右键-移除状态栏: 2 添加菜单栏 在窗口上,右键-创建…

【QT】Ubuntu 搭建 QT 环境(图形化界面安装)

介于直接使用源码编译安装 QT 耗时较长,而且需要手动编写脚本进行编译,难度较大,这里选择直接以图形化界面的方式安装 QT 。 目录 1、下载 QT 安装包 2、安装 QT 3、添加环境变量 4、cmake 引入 QT 库 5、Failed to find “GL/gl.h“ in…

巧用h2-database.jar连接数据库

文章目录 一 、概述二、实践三、解决办法 一 、概述 H2 Database是一个开源的嵌入式数据库引擎,采用java语言编写,不受平台的限制,同时H2 Database提供了一个十分方便的web控制台用于操作和管理数据库内容。H2 Database还提供兼容模式&#…

jmeter实现webservice接口测试

其实可以用jmeter两种sampler进行webservice的测试: 1、SOAP/XML-RPC Request(但是在jmeter3.2以后版本中已经取消了这个取样器) 2、HTTP请求 下面分别介绍两种方式 一、首先需要使用soupUI工具抓取webservice接口的部分需要的信息。 1、新建项目 2、新建成功的…

LeetCode【15】三数之和

题目&#xff1a; 解析&#xff1a; 参考&#xff1a;https://zhuanlan.zhihu.com/p/111715985 代码&#xff1a; public static List<List<Integer>> threeSum(int[] nums) {// 先排序Arrays.sort(nums);List<List<Integer>> result new ArrayLis…

力扣-415.字符串相加

Idea 模拟&#xff1a;竖式加法 从后面往前逐位相加&#xff0c;然后将相加的结果模10&#xff0c;添加到答案字符串中去 最后需要判断一下是否还有进位问题 需要将答案string翻转 AC Code class Solution { public:string addStrings(string num1, string num2) {string ans;…

【VR】【Unity】白马VR课堂系列-VR开发核心基础03-项目准备-VR项目设置

【内容】 详细说明 在设置Camera Rig前,我们需要针对VR游戏做一些特别的Project设置。 点击Edit菜单,Project Settings,选中最下方的XR Plugin Management,在右边面板点击Install。 安装完成后,我们需要选中相应安卓平台下的Pico VR套件,关于怎么安装PICO VR插件,请参…

项目成本超支的主要原因以及解决方法

成本超支&#xff0c;是每个项目经理在其职业生涯中都会遇到的一个问题。当项目的实际成本超过估计或预算成本时&#xff0c;就会发生成本超支。这在建筑、制造和软件开发项目中尤其常见&#xff0c;并影响着项目的盈利能力、利益相关者满意度和竞争优势。 成本超支的原因 由…

2023年中国渔业研究报告

第一章 行业概况 1.1 定义 渔业&#xff0c;作为全球经济的重要支柱之一&#xff0c;其核心活动包括捕捞、水产养殖、产品加工与销售等。其不仅是食物安全的重要保障&#xff0c;还是许多沿海和内陆地区经济发展的重要动力。 首先&#xff0c;捕捞活动是渔业的基础。通过海洋…

C语言纳秒级计时

C语言纳秒级计时 文章目录 C语言纳秒级计时函数介绍示例代码参考 函数介绍 C语言中常用的clock()函数只能精确到毫秒级&#xff0c;对应的数据类型是clock_t。 C11标准中提供了纳秒级别定时器&#xff1a;timespec_get()函数与timespec()类型。 struct timespec{time_t tv_s…

解决ERROR: No query specified的错误以及\G 和 \g 的区别

文章目录 1. 复现错误2. 分析错误3. 解决问题4. \G和\g的区别 1. 复现错误 今天使用powershell连接数据库后&#xff0c;执行如下SQL语句&#xff1a; mysql> select * from student where id 39 \G;虽然成功查询除了数据&#xff0c;但报出如下错误的信息&#xff1a; my…

如何下载IEEE Journal/Conference/Magazine的LaTeX/Word模板

当你准备撰写一篇学术论文或会议论文时&#xff0c;使用IEEE&#xff08;电气和电子工程师协会&#xff09;的LaTeX或Word模板是一种非常有效的方式&#xff0c;它可以帮助你确保你的文稿符合IEEE出版的要求。无论你是一名研究生生或一名资深学者&#xff0c;本教程将向你介绍如…