Write on the front
In the past, including the projects received now, the most used relational database is SQL server or oracle. Later, because of a request to MySQL database development project. So, I have to learn to use it. However, since learning and using it to the actual development process, there are still many problems. The following is a summary of the problems I encountered in the process of installing mysql. In order to prevent similar problems from happening again.
1. The environment of the system is win10 home edition
2. Download the MySQL installation package of Windows version on the official MySQL website.
Address: MySQL official website
Click download and the following interface will pop up. Click No, tanks, just start my download
3. After downloading, unzip and unzip the zip package to the directory you want to install. My path is as follows:
Because the computer has only one disk, it can only be put in disk C.
4. Configure environment variables
Enter computer – properties – advanced system settings – environment variables, and add the path of MySQL decompression.
5. Configure the configuration file of MySQL
Open the folder that you just unzipped, C: / / mysql-8.0.17-winx64 / mysql-8.0.17-winx64, and create a configuration file named my.ini , edit my.ini Configure the following basic information:
[mysql] default-character-set=utf8 [mysqld] port = 3306 basedir=C:\mysql-8.0.17-winx64\mysql-8.0.17-winx64 datadir=C:\mysql-8.0.17-winx64\mysql-8.0.17-winx64\data character-set-server=utf8 default-storage-engine=INNODB
6. Next, let’s start the MySQL database
First, open the CMD command line tool as an administrator.
Then, switch the directory.
The command line is as follows:
Secondly, to install mysql, the operation command is as follows.
Then, enter the initialization command.
mysqld --initialize-insecure --user=mysql
Then, the data directory will be generated under the directory C: mysql-8.0.17-winx64, mysql-8.0.17-winx64
Finally, start and enter the following command.
The operation command is as follows:
net start mysql
This proves that the connection is successful.
1. Log in to MySQL
Input operation command:
mysql -u root -p
Because the password has not been set before, the password is empty. Just press enter
2. Query user password
Command to query user password:
mysql> select host,user,authentication_string from mysql.user;
Host: the IP that allows users to log in;
User: the user name of the current database;
authentication_ String: user password;
If there is no password, the root line should be empty.
3. Set the root password
Note: after MySQL 5.7.9, the password field and the password() function are abandoned
Do not set the password as follows:
use mysql; update user set authentication_string="newpassword" where user="root";
This will give the root user’s authentication in the user table_ The newpassword value is set under the string field;
The correct steps to modify the root password are as follows:
Step 1. If the current root user authentication_ If there is content under the string field, set it to blank first, and if not, skip to step 2.
use mysql; update user set authentication_string='' where user='root'
Step 2. Use alter to modify the root password
use mysql； Alter user 'root' @'localhost 'identified by' new password '; FLUSH PRIVILEGES;
So far, the local MySQL created by myself is finished!!!
Using the graphical interface software Navicat for SQL
1. Unzip the file and copy the key
2. Open the navicat.exe
3. The user name is optional, enter the key, and then connect to the database
4. Enter the password (if MySQL has reset the password before, just fill in the new password here), and change the connection name to the one you like
Problems: the connection failed here, as shown in the figure:
Analysis of the reasons:
The reason for this error is that in versions before mysql8, the encryption rule was mysql_ native_ After mysql8, the encryption rule is caching_ sha2_ password。
1. Open CMD with administrator’s permission, enter MySQL – U root – P, enter password and enter MySQL database;
MySQL - U root - P # enter database
2. Modify the encryption rules and password and refresh them;
ALTER user 'root'@'localhost' IDENTIFIED WITH mysql_ native_ Password by 'new password'; Flush priorities; # refresh data
At this point, the installation of the required software and the configuration of the environment are all completed, and you can enjoy the world of MySQL~~
The above is the installation and use of MySQL 8.0.17 tutorial diagram introduced by Xiaobian. I hope it can help you. If you have any questions, please leave me a message and Xiaobian will reply you in time. Thank you very much for your support to developer!
If you think this article is helpful to you, please reprint, please indicate the source, thank you!