This article records in detail the installation and configuration of MySQL in the win11 system and the connection process with Navicat. Each knowledge point is explained. Not only is it installed, but you also understand it! You don't know which version to choose, what the parameters mean, or which installation method is better? There are answers here! ! !
Original address: https://blog.jiumoz.com/archives/mysql-an-zhuang-pei-zhi-yu-navicat-lian-jie
Two installation methods of MySQL
Look at the installation method of MySQL before installation, because I see that there are many installation methods on the Internet, and the installation packages are different in different ways. I am afraid that people who are half-knowledgeable like me will be confused when I look at it. Look at the difference. ;
There are mainly two ways, one needs to be installed, and the other only needs to be decompressed;
The difference in the specific download interface is as shown in the figure below, the one on the left is directly decompressed, and the one on the right is installed using a graphical interface;
-
MySQL provides ZIP Archive and MSI Installer two installation methods. The differences between them are as follows:
ZIP Archive : It is suitable for deploying MySQL to multiple servers or local development environments. You can install MySQL in different directories by decompressing the files, and its installation process is relatively simple and flexible.
MSI Installer : It is suitable for quick installation of MySQL on Windows systems. It has more complete functions and a visual installation process. During installation, it will automatically complete the installation and configuration of the components required by MySQL one by one. At the same time, it provides some additional tools, such as MySQL Workbench, etc., which are convenient for users to develop and manage databases.
If you are just installing a MySQL server, then ZIP Archive is a good choice . If you need a MySQL graphical management tool or other extra features, you should choose MSI Installer.
-
Both MySQL Community Server and MySQL Installer are installation programs for MySQL databases.
MySQL Community Server is the standard version of MySQL . It is an open source and free relational database management system officially provided by MySQL. It includes a complete MySQL database system and can meet basic database requirements.
MySQL Installer is an official installation program provided by MySQL , which can help users quickly install and configure the MySQL database system and other related tools, libraries and plug-ins. The program supports operating system platforms such as Windows, Linux, and MacOS, and also includes other MySQL tools such as MySQL Workbench.
Therefore, if you just need the MySQL database system, you can choose MySQL Community Server for installation ; if you need other MySQL tools, you can choose MySQL Installer for installation. MySQL Installer also provides some additional functions, such as backup, data recovery and Modules such as MySQL Shell.
个人是使用MySQL服务就够了,其他的都用诸如Navicat的管理工具,所以安装的是直接解压缩的版本,如果你不需要这个版本可以移步其他文章啦~
Download the installation package
MySQL official website download address: https://dev.mysql.com/downloads/mysql/
Here you will find that the addresses given by online tutorials are not consistent. The addresses given by many tutorials are: https://downloads.mysql.com/archives/installer/
Go to https://dev.mysql.com/downloads/mysql/ and the page you see is as follows, click Archives to switch to another address.
In fact, the versions are different, and it may be confusing for Xiaobai~
So what's the difference between the two versions ?
General Availability (GA) Releases
It is the version recommended to be used in the production system, and a new GA Release version is usually released every 18 to 24 months, which can be downloaded from the MySQL Developer Zone.
Archives
is a history of all MySQL releases, including GA Releases, DMRs, RCs, and others, suitable for testing, upgrading, and other purposes. Previous versions can be selected for download from Archives.How to choose ?
Download GA Releases if you need a stable release and want to use it on a production system. If you need to test or upgrade MySQL, you can choose from Archives.
If you still don’t know how to choose, and you just use MySQL to learn and develop common scenarios, just follow my tutorial~
We can choose GA Releases here, but here comes the problem again, because there are two versions
What is the difference ?
Windows (x86, 64-bit), ZIP Archive
BothWindows (x86, 64-bit), ZIP Archive Debug Binaries & Test Suite
are Windows versions of MySQL, the difference is whether Debug Binaries & Test Suite are included .
Windows (x86, 64-bit), ZIP Archive
is the standard version for deploying MySQL, which includes MySQL Server and Client, command-line tools, and other necessary files. This version does not include Debug Binaries & Test Suite , it is suitable for general users to use MySQL on Windows platform.Instead,
Windows (x86, 64-bit), ZIP Archive Debug Binaries & Test Suite
it includesDebug Binaries & Test Suite
tools that can be used to analyze and test MySQL code. This edition is generally suitable for developers and system administrators who need to locate and solve MySQL-related problems.It will be clear how to choose !
Just choose here
Windows (x86, 64-bit), ZIP Archive
.
Choose to download only
Install
Unzip the installation package
Unzip the downloaded compressed package to the location where you want to install MySQL, because this version does not need to be installed, just unzip it. This path needs to be remembered, not only to configure variables for a while, but also to facilitate troubleshooting when there are problems in future development and use.
Configure key parameters
-
my.ini
Create a new file in the decompressed directoryCreate a txt document and save it as
When saving as, select all files as the save type
-
Write the configuration parameters in the newly created my.ini, as follows:
Directories use (forward) slashes instead of backslashes. If you do use backslashes use two backslashes
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:/Coding/mysql-8.0.32-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:/Coding/mysql-8.0.32-winx64/data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
# default-storage-engine=INNODB
# 指定使用“mysql_native_password”插件认证
# default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4
MySQL character set
utf8mb4
andutf8
are both character sets in MySQL, but they are encoded differently. Before MySQL 5.5.3,utf8
only part of the UTF-8 encoding scheme was implemented in MySQL, and only part of Unicode characters could be supported. After MySQL 5.5.3, MySQL addedutf8mb4
the character set, which is a superset of UTF-8 encoding and fully supports all Unicode characters, including emoji expressions and texts in some minority languages.For BMP (Basic Multilingual Plane) characters (Unicode encoding ≤ 0xFFFF), the storage method is the same as that of , both use 1~3 bytes of storage space
utf8
.utf8mb4
However, for some Supplementary Plane characters (Unicode code > 0xFFFF),utf8
these characters cannot be stored, andutf8mb4
a character set is required to store these characters, and each character requires 4 bytes of storage space.In short,
utf8
andutf8mb4
are both character sets in MySQL, bututf8mb4
supports all Unicode characters, andutf8
only supports some Unicode characters. Therefore, when storing some special characters, you need to useutf8mb4
a character set.Authentication plugin
In MySQL 8.0 release, the default authentication plugin was changed to
caching_sha2_password
provide better security and better password management. However, if your application has not been upgraded to support the new plugin, you can set the default authentication plugin back to the old onemysql_native_password
.It should be noted that
mysql_native_password
the plugin, while still available, is relatively less secure as it uses the password hashing method from previous versions. If you are concerned about security, it is recommended to use the new authentication plugincaching_sha2_password
.At present, there are still very few people who do not support it
caching_sha2_password
, so it is good to choose him.MySQL storage engine
MySQL provides multiple storage engines, including an engine that handles transaction-safe tables and an engine that handles non-transaction-safe tables. Each storage engine has its own advantages and disadvantages. The main storage engines include:
- InnoDB: supports transaction processing, row-level locks, foreign keys and other features, has good concurrency and fault recovery capabilities, and is suitable for applications with high concurrency and large-capacity data. However, compared to other storage engines, the performance may not be satisfactory in aspects such as a large number of read operations.
- MyISAM: It is the most commonly used storage engine for MySQL. It is fast for SELECT operations, better for tables that handle large amounts of data, but slightly insufficient for INSERT and UPDATE operations. Also, MyISAM does not support transactions and foreign keys.
- Memory: An in-memory storage engine that stores data in memory instead of on disk, so it is very fast. However, it lacks persistence, data is stored in memory, and once the server crashes or restarts, all data disappears.
- Archive: An archive storage engine, suitable for some scenarios that require long-term archiving or backup of historical data. Its compression ratio is very good, but it does not support indexes, transactions, and DELETE operations.
- CSV: Store data in CSV files, suitable for importing and exporting large amounts of data. However, it also does not support features such as transactions, indexes, and foreign keys.
Generally speaking, just choose InnoDB.
Initialize MySQL
Open the command window as an administrator. If you are not an administrator, an error will be reported later ;
cd to the bin directory of MySQL installation;
Enter the initialization command mysqld --initialize --console
and press Enter;
Note the uehIUj+ek37r behind root@localhost
This is the generated password, which will be modified later;
Then enter the command mysql --install
to install MySQL
Enter the command net start mysql
to start the MySQL service
Modify the default password
Enter mysql -uroot -p
the command to log in to MySQL as root;
And enter the default password, which is the password obtained in 2.3;
Log in to MySQL after pressing Enter;
Enter the command to modify the default password:ALTER USER 'root'@'localhost' IDENTIFIED BY '你的密码';
-
verify
Enter
SHOW DATABASES;
to see which libraries are available, and now some are default tables;If the password is not changed, an error will be reported when running the above command
You must reset your password using ALTER USER statement before executing this statement.
;It is because MySQL version 5.6.6 has added the password_expired function, which allows setting the user's expiration time.
Therefore, the default password must be changed first;
Configure environment variables
- direct search
- Click on Environment Variables
-
Select Path and click Edit
-
Click New and enter the full directory of the MySQL bin directory
Such as:
D:\Coding\mysql-8.0.32-winx64\bin
, and then click OK;
So far it's done~
Database management tool (Navicat) connection
Common database management and design tools include:
- Navicat: supports a variety of database systems and provides an intuitive GUI.
- MySQL Workbench: An official tool provided by MySQL, which provides functions such as an online SQL editor, data modeling, and configuration management.
- Toad for MySQL: A database management tool provided by Quest Software that supports databases such as MySQL, MariaDB, and Percona Server.
- dbForge Studio for MySQL: The MySQL development environment provided by Devart supports functions such as query construction, SQL code debugging and data comparison.
- DBeaver: A cross-platform open source database management tool that supports many database systems, including MySQL, PostgreSQL, and SQLite.
- pgAdmin: An administrative tool for PostgreSQL databases, providing functions such as server object management, SQL editor, and visual query building.
- MongoDB Compass: a GUI tool officially provided by MongoDB for managing and querying MongoDB databases.
These tools all provide an intuitive user interface and a powerful feature set to help developers easily manage and operate the database.
Here we use Navicat, installation tutorial reference: https://blog.jiumoz.com/archives/navicatpremium16-de-po-jie-yu-an-zhuang
- Enter Navicat, create a new MySQL connection
- Configure connection information
- Confirm the test is successful
- Woohoo, it's done~
Q&A
About MySQL self-starting
Some tutorials do need to set up self-starting, not sure whether it is a problem with the installation method or a problem with the version;
The MySQL installed according to the above tutorial is normally self-started by default; you can view or set it according to the following steps;
Win+r and enter
services.msc
to open the service manager, pull down to find the MySQL service;You can view the running status and startup type;
Set self-starting, right-click the MySQL service, click Properties, and modify it after entering;
Which version of MySQL to install
I think if it is just for learning, just do the same as me and install the latest one; generally it is a compatibility problem, which is easier to solve;
But specifically, multiple aspects need to be considered, such as business requirements, database size, security, stability, and maintenance costs.
Original address: https://blog.jiumoz.com/archives/mysql-an-zhuang-pei-zhi-yu-navicat-lian-jie