MySQL-mysql 8.0.17 installation

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/Charonmomo/article/details/98440968

1. Download the installation package

Download: https://dev.mysql.com/downloads/file/?id=487686

2. Extract the installation package to a directory

Here the codecs to D: \ MySQL-8.0.17-Winx64
(FIG some files are generated in the subsequent mounting step)
Here Insert Picture Description

3. Set Environment Variables

My computer → Right → Properties → Advanced System Settings → Environment Variables

Here Insert Picture Description
Address Click "Edit" to add the MySQL bin folder

Here Insert Picture Description

4. Profiles

In MySQL folder D: \ mysql-8.0.17-winx64 create a new my.ini file, write the following information:
(Note the different installation addresses change the path)

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\\mysql-8.0.17-winx64   # 切记此处一定要用双斜杠\\,单斜杠我这里会出错,不过看别人的教程,有的是单斜杠。自己尝试吧
# 设置mysql数据库的数据的存放目录
datadir=D:\\mysql-8.0.17-winx64\\Data   # 此处同上
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8

Here Insert Picture Description

5. Install MySQL

As an administrator to open cmd, go to the MySQL installation path, enter the following command to initialize the database:

mysqld --initialize --console

Here Insert Picture Description
note! The output performed with a paragraph:
[Note] [MY-010 454] [Server] A Temporary Generated IS password for the root @ localhost: E-zyNrYHh2yF

Wherein root @ localhost: behind "zyNrYHh2yF-E" is the initial password (excluding the first spaces). In the absence of change passwords to remember this password, subsequent logins need to use.

If off fast, or did not remember, that's all right, deleted initialization datadir directory, and then perform the initialization command again, will regenerate. Of course, you can also use the security tools to force change your password, what method, his own will.
Reference: https://dev.mysql.com/doc/refman/8.0/en/data-directory-initialization-mysqld.html

6. Installation Services

MySQL installation directory in the D: \ \ bin Enter mysql-8.0.17-winx64

mysqld --install

Here Insert Picture DescriptionOriginal command would be:mysqld --install [服务名]

But behind the service name can not write, the default name for mysql. Of course, if you need to install multiple MySQL service on your computer, you can use a different name to distinguish, for example mysql5 and mysql8.

7. Start MySQL service

Start MySQL:

net start mysql

Here Insert Picture Description

(Stop the service from the command net stop mysql. By command sc delete MySQL / mysqld -remove uninstall MySQL service)

8. Change your password

In the MySQL installation directory D: \ mysql-8.0.17-winx64 \ bin, type:

mysql -u root -p

Enter the password before you can enter the MySQL.
Here Insert Picture Description
In MySQL, execute the command:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';  

Change passwords, pay attention to the end of the command; there must be, this is the syntax of mysql

Here Insert Picture Description

The installation is complete

You can look at the database installed by default

show databases;

Here Insert Picture Description
Look at the default MySQL user:

select user,host,authentication_string from mysql.user;

Here Insert Picture DescriptionThe host is the administrator root localhost, on behalf of only localhost login access. If you want to allow open other ip login, you need to add a new host. If you want to allow access to all ip, can be modified directly into a "%"

The remaining operation Reference: MySQL create user and authorization

Guess you like

Origin blog.csdn.net/Charonmomo/article/details/98440968