Steps to install MySQL on Windows using a compressed archive file

Steps to install MySQL on Windows using a compressed archive file

Recently, I need to do a small verification experiment and install MySQL. I searched online and found many tutorials and many bugs, so I translated the process from the official website directly. Please note that it is a compressed file, not an installation version. It can be used directly after decompression. I will paste the process directly below:

Installing MySQL on Windows Using a Compressed Archive

1. Extract the files to the installation directory

1) Administrator privileges
2) Select the installation location, the default is C:\mysql, and the installation location is set through the configuration file
3) Use the software to decompress. If a main directory is generated by default, please put the sub-files in the main directory to the installation location you specified.

2. Create a configuration file

A. Why use configuration files

1) Installation and data directories are different from the default locations
2) You need to customize the server settings

B. File location and name

1) When Windows starts the MySQL service, it looks for configuration files in several places, Windows directory/MySQL
2) File name my.ini/my.cnf, to avoid conflicts, use one of them
3) Make sure the MySQL server user can read the my.ini file

C. File Format

 [mysqld]
    # set basedir to your installation path
    basedir=E:/mysql
    # set datadir to the location of your data directory
    datadir=E:/mydata/data

D. Initialize the location of related files

Initialize MySQL to generate related files

E. Change directory

Move the original data + --datadir command line option each time you start the service

3. Select MySQL server type

1)mysqld: named-pipe support
2)mysqld-debug: automatic memory allocation check

Support the same storage engine. When using named pipe, be sure to close the named pipe when closing it.

4. Initialize MySQL (using mysqld)

Assume that your current directory is %BASEDIR% in the configuration file, which is the MySQL installation directory.

A. Initialize the data directory

1) bin\mysqld --initialize: contains an expired password and requires you to choose a new password
2) bin\mysqld --initialize-insecure: No root password is generated, assuming you assign a password before using the service
3) If MySQL cannot locate the exact installation directory and data storage directory

(1) Command line: bin/mysqld --default-file=C:\my.ini --initialize
(2) Configuration file as shown in 2.C.

B. Specific behavior sequence when calling the --initialize/--initialize-insecure option

1) The service checks whether the data directory exists. If it does not exist, create it. If it does exist, report an error.
2) In the data storage directory, the server creates the MySQL system database and table
3) Initialize system tables, InnoDB tables, etc.
4) The server creates a 'root'@'localhost' superuser and other saved users You should create keys for the superuser
(1) Using the --initialize option, the server generates a random key and marks it as expired, generating a warning
(2) Use --initialize-insecure to not generate a password
5) If possible, the server generates server-side auxiliary tables and files
6) If the --init-file option is used and the file contains SQL statements, the server executes the statements in the file
7) Exit the server

5. Start MySQL Server

MySQL supports named-pipe/TCP/shared memory communication
A. Start the server command: %basedir%\bin\mysqld" --console
B. Start the service: %basedir%\bin\mysqld
C. Shut down the service:%basedir%\bin\mysqld -u root -p (for password)shutdown

6. Account security settings

When you successfully initialize, start the MySQL service normally, and log in to the database, assign a new password to 'root'@'localhost'

A. Start the server, as in 5.
B. Connect to the server:

1) Use --initialize to initialize the directory: Connect to the database as root and log in using the password generated by the server. If you don't know the password, check the error log
shell> myslq -u root -p
Enter passworld: (Enter the generated password)

2) If you use --initialize-insecure:

shell>mysql -u root --skip-password

C. After the connection is successful, assign a new password to root
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

Note:

1) The configuration file is encoded in ANSI

2) The above method requires opening two windows with the command line, one to run the start service command to indicate the server process, and then enter the login command in the other window to log in to the database

3) After entering, all the inputs are SQL statements, which need to be terminated with a semicolon. You need to set and change the root password after the first login

4) Since I didn't encounter any bugs in the configuration, if you encounter a bug, you can Baidu error code/check the official website error code table

Summarize

The above are the steps I introduced to you to install MySQL using compressed archive files on Windows systems. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • MySQL data archiving tool mysql_archiver detailed explanation

<<:  How to set static IP in centOS7 NET mode

>>:  How to determine if the Linux system is installed on VMware

Recommend

JavaScript to achieve balance digital scrolling effect

Table of contents 1. Implementation Background 2....

Document Object Model (DOM) in JavaScript

Table of contents 1. What is DOM 2. Select elemen...

How to reset the root password in CentOS7

There are various environmental and configuration...

Install and use Git and GitHub on Ubuntu Linux

Introduction to Git Git is an open source version...

Detailed steps for building Portainer visual interface with Docker

In order to solve the problem mentioned last time...

Complete steps to use vue-router in vue3

Preface Managing routing is an essential feature ...

How to solve the element movement caused by hover-generated border

Preface Sometimes when hover pseudo-class adds a ...

A very detailed explanation of Linux C++ multi-thread synchronization

Table of contents 1. Mutex 1. Initialization of m...

Understanding MySQL index pushdown in five minutes

Table of contents What is index pushdown? The pri...

Solve the problem of inconsistent front and back end ports of Vue

Vue front and back end ports are inconsistent In ...

Vue custom component implements two-way binding

Scenario: The interaction methods between parent ...

How to build a K8S cluster and install docker under Hyper-V

If you have installed the Win10 system and want t...

How to set the text in the select drop-down menu to scroll left and right

I want to use the marquee tag to set the font scro...