Table of contents
Two, installation (decompression)
4. Login to MySQL
1. Download MySQL
Go to the MySQL official website to download ------- mysql official website MySQL :: Download MySQL Community Server https://dev.mysql.com/downloads/mysql/
Two, installation (decompression)
After the download is complete, what we get is a compressed package. After decompressing it, we can get the MySQL software body (that is, a folder), and we can put it in the location you want to install. Just after downloading, there is no my.ini configuration file . It is our own later configuration. Remember your unzipped path
3. Configuration
1. Add environment variables
> There are many options in the environment variable, here we only use the `Path` parameter. Why add environment variables at the beginning of initialization?
> Enter the name of an executable program in the black box (that is, CMD), and Windows will first search in the path pointed to by `Path` in the environment variable. If it finds it, it will be executed directly. If it is not found, it will be in the current working directory Look for it, and report an error if you haven't found it yet. The purpose of adding environment variables is to be able to directly call related programs in MySQL in any black box without always modifying the working directory, which greatly simplifies the operation.
(1) Advanced system settings in the computer: right click to start - find settings - open settings - enter advanced settings - click to view advanced system settings
(2) Click Environment Variables
(3) Create a new system variable
(4) Create your MySQL installation directory
(5) Edit the path path
(6) Set a new path
How to verify whether the addition is successful?
Right-click the start menu (that is, the lower left corner of the screen), select `Command Prompt (Administrator)`, open the black box, type `mysql`, and press Enter.
If it prompts `Can't connect to MySQL server on 'localhost'`, it proves that the addition is successful;
if it prompts `mysql is not an internal or external command, nor is it an operable program or batch file`, it means that the addition fails, please check again steps and try again.
2. Create a new configuration file
Create a new text file, the file name is `my.ini`, and the storage path is the `root directory` of MySQL (for example, mine is `D:\software\mysql-8.0.31-winx64`, according to your own MySQL directory location Revise). Create a text file, delete its suffix .txt, and change the file extension. The content is as follows:
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录 ----------你下载mysql时安装的文件路径
basedir=D:\software\mysql-8.0.31-winx64
# 设置mysql数据库的数据的存放目录 ---------在你下载mysql目录下自行创建一个data文件夹即可
datadir=D:\software\mysql-8.0.31-winx64\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4
3. Initialize MySQL
mysqld --initialize --console
4. Register MySQL service
Enter the following code on the command line: mysqld -install
mysqld -install
5. Start MySQL
Enter the following code on the command line: net start mysql
net start mysql // 启动mysql服务
net stop mysql // 停止mysql服务
6. Modify the default account password
Enter the following code in the command line: mysqladmin -u root password 1234`, where `1234` refers to the password of the default administrator (that is, the root account), and you can modify it to your liking.
mysqladmin -u root password 1234
At this point, the MySQL decompressed version is installed! !
4. Login to MySQL
1. Login to MySQL
Enter the following code on the command line: mysql -uroot -p1234
mysql -uroot -p1234//注意1234是你自己设置的密码
Here you can start your MySQL journey!
2. Exit MySQL
exit quit
5. Uninstall MySQL
Right-click the Start menu, select `Command Prompt (Administrator)`, and open the black box.
1. Type `net stop mysql` and press Enter.
net stop mysql
2. Type `mysqld -remove mysql` again and press Enter.
mysqld -remove mysql