Installation Tutorials

Source: Internet
Author: User
Tags mysql client mysql create mysql create user server port

Download the ZIP installation package:

MySQL8.0 for Windows Zip package:, you can not log in after entering the page. After clicking on the bottom "No Thanks, just start my download." To start the download.

or direct download: Https://

Environment: Windows 10

One, install 1.1, unzip the ZIP package to the installation directory

For example, my installation directory is: C:\Program files\mysql

1.2, configuration file

In Windows systems, the configuration file defaults to the My.ini file (or My-default.ini) in the installation directory, and some configurations need to be configured during initial installation, and most can be changed after the installation is complete. Of course, in extreme cases, everything can be changed.

We found that the extracted directory does not have a My.ini file, so it's okay to create it yourself. Add My.ini at the root of the installation, for example I am here: C:\Program Files\mysql\my.ini, write the basic configuration:

[mysqld]# Set 3306 port port=3306# set the MySQL installation directory Basedir=c:\program files\mysql# set the data storage directory for the MySQL database datadir=e:\database\ mysql\data# the maximum number of connections allowed max_connections=200# the number of failed connections. This is to prevent someone from attempting to attack the database system from the host max_connect_errors=10# the default character set used by the server is utf8character-set-server=utf8# The default storage engine that will be used when creating a new table default-storage-engine=innodb# default to use the "Mysql_native_password" plug-in authentication default_authentication_plugin= mysql_native_password[mysql]# set the MySQL client default character set default-character-set=utf8[client]# the port that is used by default when the MySQL client connects to the server port= 3306default-character-set=utf8

Note that the inside of the Basedir is my local installation directory, DataDir is my database data files to be stored in the location, the configuration needs to be configured according to their own environment.

To view all the configuration items, refer to:

1.3, initializing the database

Execute the command in the bin directory of the MySQL installation directory:


When execution is complete, the root user's initial default password is printed, such as:

C:\USERS\ADMINISTRATOR>CD C:\Program Files\mysql\binc:\program files\mysql\bin>mysqld--initialize-- console2018-04-28t15:57:17.087519z 0 [System] [MY-013169] [Server] C:\Program Files\mysql\bin\mysqld.exe (mysqld 8.0.11) initializing of server in progress as Process 49842018-04-28t15:57:24.859249z 5 [Note] [MY-010454] [Server] A Temp Orary password is generated for [email protected]: ri5rvf5x5g,e2018-04-28t15:57:27.106660z 0 [System] [MY-013170] [Server ] C:\Program Files\mysql\bin\mysqld.exe (mysqld 8.0.11) initializing of server has Completedc:\program Files\mysql\bin >

Attention! There is a paragraph in the execution output: [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: ri5rvf5x5g,e where [email PR Otected]: The following "Ri5rvf5x5g,e" is the initial password (excluding the first space). Before changing the password, you need to remember this password, subsequent logins need to use.

If your hands are cheap, close quickly, or don't remember, that's fine, delete the initialized DataDir directory, and then execute the initialization command again, and regenerate it. Of course, you can also use security tools, forced to change the password, with what method, their own discretion.


1.4, Installation Services

Execute the command in the bin directory of the MySQL installation directory (open the CMD command line as an administrator, or right-click "Open command-line window here" in the installation directory shift+):

mysqld--install [service name]

After the service name can not be written, the default name is MySQL. Of course, if you need to install more than one MySQL service on your computer, you can differentiate it with different names, such as MySQL5 and Mysql8.

After the installation is complete, you can start MySQL service from the command net start MySQL .


C:\Program files\mysql\bin>mysqld--installservice successfully installed. C:\Program files\mysql\bin>net Start Mysqlmysql service is starting: The MySQL service has started successfully. C:\Program files\mysql\bin>


Second, change password and password Authentication plugin

Execute the command in the bin directory of the MySQL installation directory:

Mysql-u root-p
This time will prompt to enter the password, remember the above step 1.3 installation password, fill in can log in successfully, into the MySQL command mode.

Prior to MySQL8.0.4, the execution

SET Password=password (' [Modified password] ');
You can change the password, but the MySQL8.0.4 starts, so the default is no. Because before, MySQL's password authentication plug-in is "Mysql_native_password", and now uses "Caching_sha2_password".

Because there are many database Tools and link packages do not support "Caching_sha2_password", for convenience, I temporarily changed back to the "Mysql_native_password" Authentication plugin.

Modify the user password and execute the command in MySQL:

ALTER USER ' root ' @ ' localhost ' identified with Mysql_native_password by ' new password ';
Modify the password verification plugin and change the password at the same time.

If you want to use the Mysql_native_password plug-in authentication by default, you can configure the Default_authentication_plugin entry in the configuration file.



C:\Program files\mysql\bin>mysql-u root-penter Password: ************welcome to the MySQL Monitor.  Commands End With; or \g.your MySQL connection ID is 8Server version:8.0.11copyright (c), 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql> ALTER USER ' root ' @ ' localhost ' identified with MYSQL_NATIVE_PASSWO Rd by ' new password '; Query OK, 0 rows affected (0.06 sec) mysql>

Reference: Https://

Here, the installation deployment is complete. Officials say the test speed is MySQL8 twice times faster than 5.

You can use the command to view the default installed database:

show databases;

Use MySQL;

Show tables;

Mysql> Show databases;+--------------------+| Database           |+--------------------+| information_schema | | mysql              | | performance_schema | | sys                |+----------- ---------+4 rows in Set (0.01 sec) mysql>

See that the MySQL database is initialized by default, where the user table stores information about MySQL users. We can look at the default MySQL user:

Select user,host,authentication_string from Mysql.user;

Mysql> Select user,host,authentication_string from mysql.user;+------------------+-----------+----------------- --------------------------+| User             | host      | authentication_string                     |+------------------+-----------+------------------------------- ------------+| Mysql.infoschema | localhost | *thisisnotavalidpasswordthatcanbeusedhere | | mysql.session |    localhost | *thisisnotavalidpasswordthatcanbeusedhere | | mysql.sys        | localhost | * Thisisnotavalidpasswordthatcanbeusedhere | | Root             | localhost | *27c237a977f4f44d3f551f1a673be14dfd232961 |+------------------+-----------+---------------- ---------------------------+4 rows in Set (0.00 sec) mysql>

The host of administrator root is localhost, which represents only localhost login access. If you want to allow other IP logins to be opened, you need to add a new host. If you want to allow all IP access, you can directly modify the "%"

To create a user:

CREATE USER ' xxh ' @ '% ' identified with Mysql_native_password by ' [Email protected]# ';

# (need to note: mysql8.0 encryption method Modified)

Select User, host, plugin, authentication_string from user\g;

Authorizing a remote database

GRANT all privileges on * * to ' xxh ' @ '% ';
#授权基本的查询修改权限, set on demand
GRANT select,insert,update,delete,create,drop,alter on *. * to ' xxh ' @ '% ';

View User Permissions
Show grants for ' xxh ' @ '% ';


mysql> use mysql;database changedmysql> CREATE USER ' xxh ' @ '% ' identified with Mysql_native_password by ' [Email prote cted]# '; #创建用户 (Note: mysql8.0 encryption modified) Query OK, 0 rows affected (0.07 sec)

To view password encryption methods:

Mysql> Select User, host, plugin, authentication_string from user;+------------------+-----------+---------------- -------+-------------------------------------------+| user | Host | Plugin | authentication_string |+------------------+-----------+-----------------------+----------------------- --------------------+| Xxh | %         | Mysql_native_password | *70fd6fb4f675e08ff785a754755b5eba6da62851 | | Mysql.infoschema | localhost | Mysql_native_password | *thisisnotavalidpasswordthatcanbeusedhere | | mysql.session | localhost | Mysql_native_password | *thisisnotavalidpasswordthatcanbeusedhere | | Mysql.sys | localhost | Mysql_native_password | *thisisnotavalidpasswordthatcanbeusedhere | | Root | localhost | Mysql_native_password | *27c237a977f4f44d3f551f1a673be14dfd232961 |+------------------+-----------+-----------------------+------------- ------------------------------+5 rows in Set (0.00 sec) MYSQL&GT 

In addition, if you need to add a new account, or other people outside the computer to access MySQL will also need to set up the built-in account host, for reference: MySQL create user and authorization Installation Tutorials

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.