table of Contents
Download the compressed package
Enter MySQL download page:
select any compressed package to download.
No need to log in, click to download directly.
Unzip the installation configuration
Choose a decompression location, here I choose D:\Installed
to be my decompression directory. Place the decompressed target folder in the decompressed directory:
Target folder : remove the upper level folder with the same name.
After extracting the following figure:
Because this compression bag missing a profile, so here we need to manually create a my.ini
file.
Create a text file and directly modify the file name and suffix.
And, on this basis, we also need to create a data 文件夹
(name custom) to save the data.
The overall structure is as follows:
As for the content of the configuration file and the role of the parameters have been marked, as shown below:
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录,一定要与上面的安装路径保持一致
basedir=D:/Installed/mysql-8.0.22-winx64
# 设置mysql数据库的数据的存放目录,自动生成,无需手动创建,当然也可以放在其他地方
datadir=D:/Installed/mysql-8.0.22-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
And always remember to modify the configuration file
basedir
anddatadir
path.datadir
At the end of the path is the name of the folder we created above to save the data.
The rest can no longer be modified.
Initial configuration and installation of MySQL service
Open the following directory: C:\Windows\System32
the cmd.exe
file to run as administrator .
Enter on the command line MySQL 8.0.22
installation directory bin
directory:
and operation of the database initialization:
mysqld --initialize
After performing the previous step, the data目录
next will generate a suffix for the .err
file, and there are initialization code. We edit and open this file and find the password.
The file naming rule is [ computer user name.err ].
The label in the picture is our user name and temporary password.
Note that the password does not include the preceding spaces .
Now, we can install MySQL服务
up.
Still in the command line just now (run as an administrator), enter the following command:
# 安装MySQL服务-----不指定服务名(默认为 MySQL)
mysqld --install
# 安装MySQL服务-----指定服务名
mysqld --install MySQL8022
If there is no service, it will prompt that the installation is successful: but if it already exists , you can skip this step, or uninstall the original service first, install it again, or change the service name:Service successfully installed.
MySQL服务
# 卸载MySQL服务-----不指定服务名(默认为 MySQL)
mysqld --remove
# 卸载MySQL服务-----指定服务名
mysqld --remove MySQL8022
As shown in the figure: the
next step is to start MySQL服务
:
re-run the command window as an administrator and enter the following command:
# net start MySQL服务名(默认为MySQL)
net start MySQL
# net start MySQL8022
Close MySQL服务
:
Run the command window as an administrator and enter the following command:
# net stop MySQL服务名(默认为MySQL)
net stop MySQL
# net stop MySQL8022
Change password and connect to the database
Reopen a normal command window, enter the bin
directory, enter the following command:
mysql -u root -p
Here you need to enter a start we get to the temporary password :
Next we have opened a database, you can now enter the following command to modify the password for the database:
ALTER user 'root'@'localhost' IDENTIFIED BY '你的密码';
The following picture:
the use of Navicat
connecting to the database, so we can verify our database password is changed successfully:
Open the MySQL just connected:
Common errors and solutions
1. It is found that the port is occupied when the database is started.
A, it is possible to modify
my.ini
a Port Number.
B. Manually disable the currently occupied port.
2. Prompt when starting the service 服务名无效
.
A. The service name is entered incorrectly.
B. Reinstall the MySQL service.
3. Prompt when connecting to the database:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
A. The MySQL service is not installed and needs to be reinstalled.
B. The MySQL service is not started, you need to start the service.
4. Prompt when logging in to the database:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
A. The password is wrong.
5. Prompt when installing the service:Install/Remove of the Service Denied!
A. The command line window is not run as an administrator.
6. Prompt when starting the service:发生系统错误 5。拒绝访问。
A. The command line window is not run as an administrator.