Problems with installing mysql

download

The download URL of the installation file is: https://dev.mysql.com/downloads/mysql/
It is for the community free version. The download is 8.0 at the beginning, but there are always problems with the installation, and there are few reference materials for the installation. 5.7.22, successfully installed
1. msi is equivalent to the installer
2. zip is an installation-free compressed program package, just unzip it, use this one

Install

After the decompression is completed, there is no setup program. This is already installed. The following configuration is required.

configure

add files

You need to add a file my.ini to the decompression directory, and enter the following code in it:

[Client]
port = 3306
 
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=F:\mysql-5.7.22-winx64
# 设置mysql数据库的数据的存放目录
datadir=F:\mysql-5.7.22-winx64\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
 
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8

The data folder will be automatically generated during initialization later.

initialization

Run the command prompt (cmd) as an administrator, enter the bin of the installation directory, and enter the command mysqld --initialize --user=mysql --console
After the initialization is successful, the data folder will be generated in the installation directory and appear initial password, remember the initial password

test

Enter mysqld --install mysql after bin> and
display Service successfully installed. It means the installation is successful.

start up

Entering net start mysql after bin>
shows that the startup is successful

password login

Enter mysql -u root -p after bin>, enter the initial password, you can log in to mysql

Change the initial password

After logging in, enter set password=password('new password') after mysql>; the password can be changed, note the semicolon at the end

Modifying environment variables

First, create a new system variable MYSQL_HOME (mysql root directory), and configure the variable value to be F:\mysql-5.7.22-winx64;
then, edit the system variable Path and add ;%MYSQL_HOME%\bin to the Path variable value. Note the preceding semicolon.
Now you can log in to mysql with the new password.

login

We can create a mysql.bat batch file on the desktop, the content:
cd F:\mysql-5.7.22-winx64\bin
mysql -u root -p
Run this file and enter the password directly to log in to mysql.
Premise: The premise is that the mysql service must be opened, otherwise an error will occur. The steps to open the mysql service are: press win+R, enter in the input field: net start mysql or enter the cmd window and enter: net start msyql to open the mysql service. Note that for me, I have to switch to the installation directory of the F drive to start. In this way, we have successfully started mysql through cmd as an administrator, and then open the mysql.dat file as an administrator.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325101913&siteId=291194637