1. Requirement Background
Recently, I needed to use the database on a computer with average performance, so I decided to install the MySQL database. The previous installation was automated using WorkBench, but the installation process was too slow and took up too much space, so I downloaded the zip archive. The reason for choosing MySQL8.0 is because:
ps: I didn't read the introduction at all, I was crazy all the way, and only found out that it was MySQL 8.0 during installation.
2. Installation
1) Unzip
The unzipped directory and files.
Note: Do not modify and move at will! ! !
2) Environment variables
Select the bin directory under the installation directory
Configure environment variables.
3) Automatically generate relevant configuration files
Configure the environment variables, enter net start mysql, it will show that the startup is successful
However, I can't log in, check the background processes and services, and MySQL has not started successfully.
Entering the mysql --console password will show that the data directory is missing because mysql is not initialized.
Enter mysqld --initialize to initialize the data directory. There is an additional data directory in the MySQL directory, and there will also be various data in it.
The MySQL service can start normally.
4) View random password
After the MySQL service is started, a password is required to log in to the root account, otherwise an error will be reported.
Many students will wonder why they ask for a password without setting a password. This is a random password generated by MySQL in xxx-PC.err during initialization.
5) Login successfully
Enter a random password to log in to the system
3. Change password
1) Random password has no operation authority
After logging in to the system with a random password, you do not have permission to operate the database and tables, and you need to change the password.
Use set password for root@localhost = password('123'); modification will report an error, because the new version of the command has changed
2) The new version of the command is different from the old version
The command in the new version is as follows set password for root@localhost = '123';, which is more concise than the old version.
3) The modification is successful
Successfully modified
4) Operate databases and tables
Databases and tables can be manipulated
4. Summary
If there is a problem, look at the official website documentation!