MySQL 8.0.15 installation tutorial and pitfall summary under Windows
MySQL 是一个关系型数据库管理系统,由瑞典 MySQL AB 公司开发,2008 年被 SUN 公司收购,后 SUN 公司又被 Oracle 公司收购。
相关推荐:《mysql视频教程》
一、下载
MySQL 官网 www.mysql.com/
点击 DOWNLOADS
进入下载地址,会看到几个不同的版本:
- MySQL Enterprise Edition:企业版(收费)
- MySQL Cluster CGE:高级集群版(收费)
- MySQL Community Edition:社区版(开源免费,但官方不提供技术支持)
通常我们用的都是社区版。点击进入社区版,看到一大堆东西,有点愣住了,不用急,其实点第一个 MySQL Community Server
的下载就可以了。
所以真正的下载地址其实是:dev.mysql.com/downloads/m…
拉到下面,选择 Windows 系统。

这里提供安装版和解压版,安装版是 32 位的(当然 64 位系统下也能安装),解压版是 64 位的。

点击 Download
后会跳转到如下页面,这是叫你注册/登录的,不理它,点击左下角的 No thanks, just start my download.
开始下载。

安装版是 32 位的,而现在的机器多半是 64 位机,虽然 32 位的程序也可以安装,但是并不建议。安装版的安装也比较容易,所以这里只讲解压版的安装。
二、解压版配置
1、配置环境变量
将安装包解压到你要安装的目录,将 bin
目录添加至环境变量。

2、配置 MySQL 8.0.15 installation tutorial and pitfall summary under Windows
在根目录下新建一个 MySQL 8.0.15 installation tutorial and pitfall summary under Windows
文件。

在 MySQL 8.0.15 installation tutorial and pitfall summary under Windows
中添加如下配置:
[mysqld]; 设置3306端口port=3306; 设置mysql的安装目录basedir=C:\\gl\\SQL\\mysql-8.0.18-winx64; 设置mysql数据库的数据的存放目录datadir=C:\\gl\\SQL\\mysql-data; 允许最大连接数max_connections=200; 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统max_connect_errors=10; 服务端使用的字符集默认为UTF8character-set-server=utf8; 创建新表时将使用的默认存储引擎default-storage-engine=INNODB; 默认使用“mysql_native_password”插件认证default_authentication_plugin=mysql_native_password[mysql]; 设置mysql客户端默认字符集default-character-set=utf8[client]; 设置mysql客户端连接服务端时默认使用的端口port=3306default-character-set=utf8复制代码
注意:basedir 和 datadir 要改成你自己的目录。
陷阱:
default_authentication_plugin=mysql_native_password
这一句必须要加上,否则可能导致 root 的初始密码无法登陆。
3、初始化数据库
以管理员身份 运行 cmd,切换至安装目录的 bin 目录下,输入如下命令:
mysqld --initialize --console复制代码
默认的服务名就是 mysql
,也可以指定服务名
mysqld --initialize --console 服务名复制代码
一般是不会去指定服务名的,但是如果你的电脑上需要安装多个 MySQL 服务,就可以用不同的名字区分。
执行成功后,会显示 root
的初始密码,如下图,这个密码需要保存下来。

如果命令中不加 --console
,则在 cmd 窗口将不显示日志信息。可以到 data 目录(MySQL 8.0.15 installation tutorial and pitfall summary under Windows 中 datadir 配置的目录)下找一个 .err 的文件,也可以查看日志信息。
陷阱 1
可能会报“找不到 MSVCP140.dll”

MSVCP140.dll 是 Visual Studio C++ 2015 Redistributable 的组成文件。
一般出现这个问题,是因为没有安装 Visual C++ Redistributable for Visual Studio 2015 所致。这个必须安装,否则后面服务无法启动。 下载地址:www.microsoft.com/zh-CN/downl…
如果已安装,则可以修复一下。
亦可下载一个 MSVCP140.dll,复制到 C:\Windows\System32
,运行如下批处理命令注册 dll
@echo 开始注册 copy msvcp140.dll %windir%\system32\ regsvr32 %windir%\system32\msvcp140.dll /s @echo msvcp140.dll注册成功 @pause复制代码
注册成功之后再运行上述 MySQL 命令,就可以正常初始化数据库了。当然不建议这么做。
陷阱 2
执行完成之后,仔细查看输出的信息,可能会有如下警告:
'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.复制代码
utf 8 目前是字符集 UTF8MB3 的别名,在将来的版本中将被 UTF8MB4 替换。请考虑使用 UTF8MB4,以便明确无误。
如果出现的话,我们只需将 MySQL 8.0.15 installation tutorial and pitfall summary under Windows 文件中的 utf8 替换成 UTF8MB4。
3.2、安装服务
安装服务:
mysqld -install复制代码
启动服务:
net start mysql复制代码
如果上一步中你指定了另外的服务名,将 mysql
改为你指定的服务名。
登录数据库:
mysql -u root -p复制代码
这时提示需要输入密码,就是前文让你保存的密码。
登录成功后显示如下:

修改密码:执行以下语句,即可将密码改为 root。
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';复制代码

The above is the detailed content of MySQL 8.0.15 installation tutorial and pitfall summary under Windows. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

VS Code can run on Windows 8, but the experience may not be great. First make sure the system has been updated to the latest patch, then download the VS Code installation package that matches the system architecture and install it as prompted. After installation, be aware that some extensions may be incompatible with Windows 8 and need to look for alternative extensions or use newer Windows systems in a virtual machine. Install the necessary extensions to check whether they work properly. Although VS Code is feasible on Windows 8, it is recommended to upgrade to a newer Windows system for a better development experience and security.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.