2020My SQL server configuration and installation are here!

One sentence of the day, to the most precious of you: Maturity is to step your pride on the ground at a sudden moment and let it bloom into flowers or become mud.

Recently I was thinking about using a database after writing a small program, so I installed MySQL on my computer and ran it successfully. I will share the tutorial today.

So what is a MySQL database?

Simply put, MySQL is a multi-user, multi-threaded and open source SQL database. It is a client/server structured application. It consists of a server daemon mysqld and many different client programs and libraries.

As for why I chose MySQL as my database, of course, the main reason is because of its fast speed. One of the fastest SQL (Structured Query Language) databases currently on the market is MySQL Server, which is produced by TcX DataKonsultAB in Sweden. Development. And it also provides programming tools that are rare in other databases. MySQL is also free for individual users. Of course, you still need to pay a certain fee to develop an app. See the official website for details. (Https://www.mysql.com/)

Download and install MySQL

First we have to go to the official website of MySQL, the URL is as follows: https://www.mysql.com/

The following is the home page of the official website:
Insert picture description here

We click on DOWNLOADS above and find MySQL community (GPL) Download in the figure below.
Insert picture description here

After entering, we can see many versions. The editor here chooses MySQL community Server. After clicking, you can download it.
Insert picture description here

After entering, we can see the download page, where I will use a digital logo, such as:

Here is the archive, you can download the previous version of MySQL

Here comes according to your own computer system, if the editor is Windows, choose Windows.

Here is the latest official version, I chose this one. The following is a beta version, which may not be very stable, so I did not download it. After selecting it, click download on the right.

To: The editor here downloads Zip compressed files, and the other is msi, but the editor is still used to zip compressed files.
Insert picture description here

After clicking download, you will enter the following page, select the place where the editor draws a circle (meaning thank you, start downloading directly, which can avoid the complicated operation of registration and login)
Insert picture description here

After the download is complete, you will get a compressed package, directly drag the decompressed file to your Program Files folder, as follows:
Insert picture description here
MySQL environment configuration

About simple environment configuration: right click my computer -> properties -> advanced system settings -> system variables

Then find and click path, then click New, add after it: the path of your mysql bin folder (as in the editor): D:\Program Files\mysql-8.0.21-winx64\bin
Insert picture description here

Since there is no default configuration file in our mysql file, we need to create a new .ini configuration file, the new file name is my-default.ini (create a text file, and then modify the file suffix). The contents are as follows:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = D:\Program Files\mysql-8.0.21-winx64
# datadir = D:\mysql-server\data
# port = .....
# server_id = .....
#设置服务器字符集为utf8
character_set_server=utf8
collation-server=utf8_general_ci
#设置mysql的安装目录
basedir = D:\Program Files\mysql-8.0.21-winx64
#设置mysql的数据文件存放目录
datadir = D:\Program Files\mysql-8.0.21-winx64\data
#设置mysql服务所绑定的端口
port = 3306
#设置mysql允许的最大连接数
max_connections=15
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
[client] 
#设置客户端字符集
default-character-set=utf8
[WinMySQLadmin]
Server = D:\Program Files\mysql-8.0.21-winx64\bin\mysqld.exe
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

Remember to pay attention to the several paths inside, and be sure to modify it to the path where your mysql folder is located. For example, the directory that the editor puts is D:\Program Files\mysql-8.0.21-winx64, so the above configuration paths are all This one! ! !

Be sure to modify the path where your mysql folder is located! ! !
Be sure to modify the path where your mysql folder is located! ! !
Be sure to modify the path where your mysql folder is located! ! !

Next, you can run MySQL through the command line. Remember to open it as an administrator, otherwise you will get an error about insufficient permissions! ! !

The command is as follows: mysqld -install If the following prompt appears, the installation is successful.
Insert picture description here
The command to start the service is: net start mysql An error will appear at this time, as follows:
Insert picture description here

The system prompts that it cannot be started, and the error is 3534. We use the mysqld --console command to view the error log. The system prompts us that there is no \data file found in MySQL.
Insert picture description here
At this time, we need to create a new \data file. We use the command to enter mysql For the path of the folder, enter the following command: mysqld --initialize-insecure --user=mysql
Regarding how to enter the path of the MySQL folder on the command line, we need to type cd\, enter the drive letter selection, and then hit D: to enter The MySQL directory should always be in the command line just now. If you reopen it, you have to cd to open the MySQL file directory. The detailed command process is as follows:
Insert picture description here
After the above command is executed, MySQL will create a data folder by itself and build it. The default database, the login user name is root, and the password is blank. At this point, the MySQL service has started successfully!

After the service starts successfully, we can enter the command: mysql -u root -p (there is no password for the first login, just press Enter), the following window will appear:
Insert picture description here
the login is successful as shown in the figure~

Guess you like

Origin blog.csdn.net/m0_46259251/article/details/109262263