MySQL installation configuration and connection to Navicat

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;
image-20230412165312005

  • 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.

image-20230412112147855

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) ReleasesIt 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.

    Archivesis 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

image-20230412113606691

  • What is the difference ?

    Windows (x86, 64-bit), ZIP ArchiveBoth Windows (x86, 64-bit), ZIP Archive Debug Binaries & Test Suiteare Windows versions of MySQL, the difference is whether Debug Binaries & Test Suite are included .

    Windows (x86, 64-bit), ZIP Archiveis 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 Suiteit includes Debug Binaries & Test Suitetools 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

image-20230412113636042

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.iniCreate a new file in the decompressed directory

    Create a txt document and save it as

    When saving as, select all files as the save type

image-20230412153628331

  • 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

    utf8mb4and utf8are both character sets in MySQL, but they are encoded differently. Before MySQL 5.5.3, utf8only 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 added utf8mb4the 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. utf8mb4However, for some Supplementary Plane characters (Unicode code > 0xFFFF), utf8these characters cannot be stored, and utf8mb4a character set is required to store these characters, and each character requires 4 bytes of storage space.

    In short, utf8and utf8mb4are both character sets in MySQL, but utf8mb4supports all Unicode characters, and utf8only supports some Unicode characters. Therefore, when storing some special characters, you need to use utf8mb4a character set.

  • Authentication plugin

    In MySQL 8.0 release, the default authentication plugin was changed to caching_sha2_passwordprovide 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 one mysql_native_password.

    It should be noted that mysql_native_passwordthe 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 plugin caching_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:

    1. 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.
    2. 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.
    3. 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.
    4. 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.
    5. 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 ;

image-20230412154755531

cd to the bin directory of MySQL installation;

image-20230412152024520

Enter the initialization command mysqld --initialize --consoleand press Enter;

image-20230412153744525

Note the uehIUj+ek37r behind root@localhost

This is the generated password, which will be modified later;

Then enter the command mysql --installto install MySQL

image-20230412154728359

Enter the command net start mysqlto start the MySQL service

image-20230412154838945

Modify the default password

Enter mysql -uroot -pthe command to log in to MySQL as root;

And enter the default password, which is the password obtained in 2.3;

image-20230412155121750

Log in to MySQL after pressing Enter;

image-20230412155228390

Enter the command to modify the default password:ALTER USER 'root'@'localhost' IDENTIFIED BY '你的密码';

image-20230412155610143

  • 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;

image-20230412160130767

Configure environment variables

  • direct search

image-20230412152424225

  • Click on Environment Variables

image-20230412152513595

  • Select Path and click Edit

    image-20230412152632676

  • 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;

image-20230412152720823

So far it's done~

Database management tool (Navicat) connection

Common database management and design tools include:

  1. Navicat: supports a variety of database systems and provides an intuitive GUI.
  2. MySQL Workbench: An official tool provided by MySQL, which provides functions such as an online SQL editor, data modeling, and configuration management.
  3. Toad for MySQL: A database management tool provided by Quest Software that supports databases such as MySQL, MariaDB, and Percona Server.
  4. dbForge Studio for MySQL: The MySQL development environment provided by Devart supports functions such as query construction, SQL code debugging and data comparison.
  5. DBeaver: A cross-platform open source database management tool that supports many database systems, including MySQL, PostgreSQL, and SQLite.
  6. pgAdmin: An administrative tool for PostgreSQL databases, providing functions such as server object management, SQL editor, and visual query building.
  7. 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

image-20230412161135427

  • Configure connection information

image-20230412161455343

  • Confirm the test is successful

image-20230412161512198

  • Woohoo, it's done~

image-20230412161613825

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;

  1. Win+r and enter services.mscto open the service manager, pull down to find the MySQL service;

    You can view the running status and startup type;

    image-20230412164151454

  2. Set self-starting, right-click the MySQL service, click Properties, and modify it after entering;

    image-20230412164236797

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

Welcome to follow the blogger's personal mini program!

Guess you like

Origin blog.csdn.net/qq_45730223/article/details/130112458