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

AI Hentai Generator
Generate AI Hentai for free.

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 reasons why you cannot log in to MySQL as root are permission problems, configuration file errors, password inconsistent, socket file problems, or firewall interception. The solution includes: check whether the bind-address parameter in the configuration file is configured correctly. Check whether the root user permissions have been modified or deleted and reset. Verify that the password is accurate, including case and special characters. Check socket file permission settings and paths. Check that the firewall blocks connections to the MySQL server.

When MySQL modifys table structure, metadata locks are usually used, which may cause the table to be locked. To reduce the impact of locks, the following measures can be taken: 1. Keep tables available with online DDL; 2. Perform complex modifications in batches; 3. Operate during small or off-peak periods; 4. Use PT-OSC tools to achieve finer control.

Data Integration Simplification: AmazonRDSMySQL and Redshift's zero ETL integration Efficient data integration is at the heart of a data-driven organization. Traditional ETL (extract, convert, load) processes are complex and time-consuming, especially when integrating databases (such as AmazonRDSMySQL) with data warehouses (such as Redshift). However, AWS provides zero ETL integration solutions that have completely changed this situation, providing a simplified, near-real-time solution for data migration from RDSMySQL to Redshift. This article will dive into RDSMySQL zero ETL integration with Redshift, explaining how it works and the advantages it brings to data engineers and developers.

1. Use the correct index to speed up data retrieval by reducing the amount of data scanned select*frommployeeswherelast_name='smith'; if you look up a column of a table multiple times, create an index for that column. If you or your app needs data from multiple columns according to the criteria, create a composite index 2. Avoid select * only those required columns, if you select all unwanted columns, this will only consume more server memory and cause the server to slow down at high load or frequency times For example, your table contains columns such as created_at and updated_at and timestamps, and then avoid selecting * because they do not require inefficient query se

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

MySQL has a free community version and a paid enterprise version. The community version can be used and modified for free, but the support is limited and is suitable for applications with low stability requirements and strong technical capabilities. The Enterprise Edition provides comprehensive commercial support for applications that require a stable, reliable, high-performance database and willing to pay for support. Factors considered when choosing a version include application criticality, budgeting, and technical skills. There is no perfect option, only the most suitable option, and you need to choose carefully according to the specific situation.

MySQL cannot run directly on Android, but it can be implemented indirectly by using the following methods: using the lightweight database SQLite, which is built on the Android system, does not require a separate server, and has a small resource usage, which is very suitable for mobile device applications. Remotely connect to the MySQL server and connect to the MySQL database on the remote server through the network for data reading and writing, but there are disadvantages such as strong network dependencies, security issues and server costs.

MySQL database performance optimization guide In resource-intensive applications, MySQL database plays a crucial role and is responsible for managing massive transactions. However, as the scale of application expands, database performance bottlenecks often become a constraint. This article will explore a series of effective MySQL performance optimization strategies to ensure that your application remains efficient and responsive under high loads. We will combine actual cases to explain in-depth key technologies such as indexing, query optimization, database design and caching. 1. Database architecture design and optimized database architecture is the cornerstone of MySQL performance optimization. Here are some core principles: Selecting the right data type and selecting the smallest data type that meets the needs can not only save storage space, but also improve data processing speed.