MySQL is completely disintegrated: installation, deployment and preparation

Download and install

In the era of high-speed Internet, our lives have undergone tremendous changes, from shopping (Taobao, JD), travel (Didi, Kuaigou), payment (Alipay, WeChat), etc., covering all aspects of our lives. We use these systems and When applied, a large amount of data information will be obtained and stored on it,

That information must always be implemented and stored persistently before it can be used in a variety of business scenarios. So we store the data in the database. Commonly used databases are mysql, oracle, sqlserver, db2, etc.

MySQL is a kind of relational database. It uses standardized SQL language to access the database. It has the characteristics of small size, fast speed, low overall cost, and is open source. In terms of application, MySQL is the best RDBMS (relational database management system) One of the application software.

In the domestic environment, MySQL also ranks first in the Internet company usage rate, the information is very complete, and the community is also very active. Therefore, our series mainly learns MySql, and maximizes its breakdown, fragmentation of its details, and understands it. The essence of.

download

Mysql download address: https://dev.mysql.com/downloads/mysql/, the latest community version is version 8.0.22, we can get the historical version through Archives:

 

Here we can use version 5.7.30 and download the corresponding installation package according to the environment of our computer.

 

After the download is complete, unzip the folder and unzip it to the D:\Setup\mysql-5.7.30-winx64 directory on the demo side:

Configuration

At this time, we will find that the data directory and my.ini file are missing in the decompressed directory, so we add it. When initializing MySQL, a data directory will be created automatically (if not, add one yourself), so just configure a my. The ini file will do.

So we then configure the MySQL configuration file, create a my.ini configuration file in the unzipped directory , edit my.ini and write the following information:

 1 [Client]
 2 port = 3306
 3 
 4 [mysqld]
 5 #Set 3306 port
 6 port = 3306
 7 # Set the mysql installation directory (note that the address corresponds to)
 8 basedir=D:\mysql-5.7.30-winx64
 9 # Set the storage directory of the mysql database data (note that the address corresponds to)
10 datadir=D:\mysql-5.7.30-winx64\data
11 # Maximum number of connections allowed
12 max_connections=200
13 # The character set used by the server defaults to the 8-bit encoding latin1 character set
14 character-set-server=utf8
15 # The default storage engine that will be used when creating a new table
16 default-storage-engine=INNODB
17 
18 [mysql]
19 # Set the default character set of the mysql client
20 default-character-set=utf8

Installation and deployment

Next, we start and initialize MySQL, open the cmd command line tool as an administrator, switch directories, and enter the bin directory in the MySQL folder just decompressed:

1 cd /d D:\Setup\mysql-5.7.30-winx64\bin

Then enter the following command:

1 mysqld --initialize --user=mysql --console

 

The initialization is successful. At this time, you will find that the system creates a data directory under the mysql-5.7.30-winx64 directory and generates an initial password: root@localhost: skhjH5aK%bLd.

1 2020-10-24T01:31:41.026376Z 0 [Warning] CA certificate ca.pem is self signed.
2 2020-10-24T01:31:41.218257Z 1 [Note] A temporary password is generated for root@localhost: skhjH5aK%bLd

skhjH5aK%bLd is the initial password, which is needed for subsequent logins. You can also change the password after login. We will find a place to back up and store the password so that it will not be lost.

Then continue to enter the mysql installation command:

1 mysqld --install mysql

The installation feedback information is Service successfully installed. It means the installation is successful.

After installation, enter the following command to start mysql:

1 net start mysql

Note: If the startup fails, you can find mysql in the windows service, right-click and manually start the mysql service

Login and change password

When the MySQL service is running, we can log in to the MySQL database through the client tool that comes with MySQL, that is, enter the following format command to log in to MySQL:

1 mysql -h hostname -u username -p

Parameter Description:

-h : Specify the MySQL host name that the client wants to log in. If you log in to this machine (this machine is localhost or 127.0.0.1), this parameter can be omitted;

-u : login username;

-p : login password, if the password of the user to log in is empty, you can ignore it.

So we enter the following command symbol: mysql -u root -p, Enter password: will appear, asking us to enter the password, just enter the default password we provided when we installed it.

To modify the mysql login password, enter the following command (note that you need to enter a semicolon). There are several ways to reset the password. We can discuss them slowly in the following chapters.

1 set password=password('new password');

Environment variable configuration

Then we configure the environment variables of mysql.

1. Add the mysql home variable and configure it to our MySQL installation directory: D:\Setup\mysql-5.7.30-winx64

 

2. Modify the system variable Path and add %MYSQL_HOME%\bin to the Path variable:

Once configured, you can log in with the new password next time you start it.

Visualization tool

There are many visualization tools for MySQL, you can refer to: https://www.cnblogs.com/runw/p/12109991.html, choose the one that suits you.

We use NaviCat here. After the installation is complete, start it, select the connection pool, enter the user name, and the password that we configured just now. The default is the port of 3306 and the user name of root. You don’t need to change it. If you create other accounts and ports, you can adjust them.

Can be used happily:

 

Original link: https://www.cnblogs.com/wzh2010/p/13842954.html

If you think this article is helpful to you, you can forward it and follow it for support

 

Guess you like

Origin blog.csdn.net/weixin_48182198/article/details/109298665