mysql 8.0. 12 Installation tutorial

  • 2021-11-02 03:02:45
  • OfStack

Recorded the mysql 8.0. 12 installation tutorial for your reference

Windows

First download the compressed package from official website;

Unzip in the installation directory;

Enter the compressed directory and create a new my. ini under the directory. The configuration contents are as follows;


[mysqld]
#  Settings 3306 Port 
port=3306
#  Settings mysql Installation directory of 
basedir=D:\\mysql\\mysql-8.0.12-winx64 #  Remember here 1 Be sure to use double slashes \\ Single slash I will make mistakes here, but look at other people's tutorials, and some are single slashes. Try it yourself 
#  Settings mysql The storage directory of the data in the database 
datadir=D:\\mysql\\mysql-8.0.12-winx64\\Data #  Same here as above 
#  Maximum number of connections allowed 
max_connections=200
#  The number of connection failures allowed. This is to prevent an attempt to attack the database system from this host 
max_connect_errors=10
#  The character set used by the server defaults to UTF8
character-set-server=utf8
#  Default storage engine to be used when creating new tables 
default-storage-engine=INNODB
#  Default uses " mysql_native_password "Plug-in authentication 
default_authentication_plugin=mysql_native_password
[mysql]
#  Settings mysql Client default character set 
default-character-set=utf8
[client]
#  Settings mysql The default port used when the client connects to the server 
port=3306
default-character-set=utf8

Add directories to environment variables;

Run cmd as an administrator;

Execute the command under the bin directory of the MySQL installation directory: mysqld-initialize-console; When the execution is complete, the initial password of the root user is printed, such as:


[Server] A temporary password is generated for root@localhost: rI5rvf5x5G,E

Among them, rI5rvf5x5G and E are initial passwords, which do not contain spaces, so don't close them quickly;

Execute the command in the bin directory of the MySQL installation directory: mysqld-install;

Once the installation is complete, you can start the service of MySQL with the command net start mysql. Stop service by commanding net stop mysql. Uninstall the MySQL service by commanding sc delete MySQL/mysqld-remove;

Execute the command under the bin directory of the MySQL installation directory: mysql-u root-p (log in to mysql with an root account and the password is empty), and then enter the above password;

Execute the command in MySQL:


ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ' New password '; 

Pay attention to the ";" at the end of the command. 1 must have, this is the syntax of mysql;

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

Create a user:


CREATE USER 'xxh'@'%' IDENTIFIED WITH mysql_native_password BY 'xxh123!@#';
grant all on *.* to root@'%'identified by 'password'  Settings 1 A root Users allow remote login 

Check users:


select user, host, plugin, authentication_string from user\G;

Authorize all permissions:


GRANT ALL PRIVILEGES ON *.* TO 'xxh'@'%' ; 

Authorize basic query modification permissions, and set them as required:


GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON *.* TO 'xxh'@'%';

View user rights.


show grants for 'xxh'@'%';

LINUX

There are a few points to note:

1. After installing mysql, change the database coding settings at/ect/my. cnf, and add the following fields respectively;


[mysql]
default-character-set=utf8
 
[client]
default-character-set=utf8
 
[mysqld]
character-set-server=utf8

2. Initialize the security settings of the database: mysql_secure_installation, which is convenient for remote connection;

3. Use Navicat to connect to the database.

Wonderful topic sharing:

mysql Installation Tutorial for Different Versions

mysql 5.7 Versions Installation Tutorial

mysql 5.6 Version Installation Tutorial

mysql 8.0 Versions Installation Tutorial


Related articles: