CentOS 8 install MySQL8 record

Windows 10 install MySQL8 record

Remember that before installing, you need to uninstall the previously installed version of MySQL 5.
Otherwise, the installation fails: Go
Insert picture description here
to the official website to download the installation package.
Download address: https://dev.mysql.com/downloads/mysql/
Ignore account registration or login, download the zip package directly, and unzip it.

D:\mysql-8.0.23-winx64
Create new
my.ini content:

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\\mysql-8.0.23-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\\mysql-8.0.23-winx64\\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8

Configure the system environment

MYSQL_HOME

Add %MYSQL_HOME%\bin to the path

5: As an administrator, open the cmd window and jump the path to E:\mysql-8.0.11-winx64\bin

Initialize the command mysqld --initialize --user=mysql --console
enter mysqld -install to add services

Enter net start mysql to start the service

Enter mysql -u root -p to log in to the database. At this time, you are prompted for a password, and then log in with your above password.
Modify the password statement: ALTER USER root@localhost IDENTIFIED BY '123456'; Modify the password: 123456

Insert picture description here

Insert picture description here

CentOS 8 install MySQL8 record

First, check if MySQL is already installed:
yum list installed mysql
or
rpm -qa | grep mysql

If it is already installed, consider uninstalling. Before uninstalling, turn off the mysql service, and then use the command:
rpm -ev --nodeps mysql-errmsg-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64 mysql-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64 mysql-server-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64 mysql80-community-release-el8-1.noarch mysql-common-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64

Verify uninstall:rpm -qa | grep mysql

Install Yum Repository:
wget https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpm

Use rpm to install MySQL:
rpm -ivh mysql80-community-release-el8-1.noarch.rpm

Use yum to install mysql service:
yum install mysql-server

Set boot up:

systemctl enable mysqld.service
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
systemctl enable [email protected]
Created symlink /etc/systemd/system/multi-user.target.wants/[email protected] → /usr/lib/systemd/system/[email protected].

Question:
What is the difference between mysqld.service and [email protected]?

Start the service:
systemctl start mysqld.service

Check whether to start the MySQL service
ps -ef|grep mysql

Check whether it is set to start the MySQL service at boot:
systemctl list-unit-files|grep mysqld

If you do not execute:, the systemctl enable [email protected]output will be:

[root@centos170 ~]# systemctl list-unit-files|grep mysqld
mysqld.service                              enabled
[email protected]                             disabled

Enter mysql, you can enter the command line, query version:
select version();
get: 8.0.21

View all default databases:
show databases;
output:

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+

Note: For most statements, you need to enter a terminating semicolon ;.

As mentioned above, you mysqlcan enter the command line client directly by using it. In addition, you mysql -uroot -pcan enter the mysql client directly by typing and pressing Enter, that is, the root user does not have a password! ! !
Insert picture description here
However, the local client using visualization tools DataGrip connection for easy subsequent data query and display, but the connection fails, the error message: SQLException: null, message from server: "Host 'XXX' is not allowed to connect.
Reference
This exception is that the database only allows localhost or 127.0.0.1 to be accessed, and remote access is not allowed.

Switch DB: use mysql
view user and corresponding host information:

select user,host from user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+

It can be seen that the root user only allows host access to localhost, so it needs to be updated: Take update user set host='%' where user='root';
effect:FLUSH PRIVILEGES;

You must enter the User user name and cannot be empty.
Insert picture description here
CentOS 8 does not need to enter the user name and password to connect to mysql, or enter root and an empty password.

https://www.cnblogs.com/weixiaofantasy/p/12667912.html

Incorrect password: The
javax.net.ssl.SSLHandshakeException: Received fatal alert: protocol_version.
user name and password must be entered for local connection. Connect to mysql on that machine, no need!

Set username and password:

use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
FLUSH PRIVILEGES;

Random password generation

Before MySQL 8.04, execute: SET PASSWORD=PASSWORD('[new password]'); But starting from MySQL 8.0.4, this default is not working. Because before, the MySQL password authentication plug-in was "mysql_native_password", but now it uses "caching_sha2_password".

For CentOS8, there is no password to install mysql8 from the default source, you can directly enter mysql for use

mysql -uroot -pxxx
directly run the error:
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user'root'@'localhost' (using password: YES)
mysql -uroot -p
and then enter the password;

Guess you like

Origin blog.csdn.net/lonelymanontheway/article/details/113352925