Ubuntu20.04 deploys MySQL 8.0.25

1 Install MySQL

The Ubuntu20.04 soft warehouse deploys MySQL8.0 version by default. The client is automatically installed when the MySQL server is installed.

1.1 Server installation

# 服务端,运行mysql服务,代码实现数据存取
sudo apt-get install mysql-server
Insert picture description here

1.2 MySQL version

Insert picture description here

2 configuration

2.1 Log in to MySQL

By default, the root user has no password, and you can log in directly by pressing Enter.

sudo mysql -u root -p
Insert picture description here

2.2 View the user table

Enter the mysql database and view the user table.

use mysql;
select Host, User, plugin from user;
Insert picture description here

2.3 Modify root password

Modify the root password to be compatible with the old version of MySQL. Use the password to log in to MySQL.
mysql_native_password is compatible with the old version. Use a password to log in to MySQL.

Insert picture description here
  • log in
mysql -u root - p
  • View the root encryption method at this time
Insert picture description here

2.4 Authorize any host

The root user authorizes any host to log in, and modify the Host to%

update user set Host='%' where User='root';
Insert picture description here

2.5 Open remote login

Open the remote login and cancel the localhost binding:
File path:
/etc/mysql/mysql.conf.d
Edit the file and comment bind-address.

vim mysqld.cnf
Insert picture description here

2.6 Remote connection

Insert picture description here

3 summary

  • Ubuntu20.04 installs MySQL8.0 by default;
  • MySQL8.0 default root password is empty, password authentication is auth_socket;
  • Modify password login: mysql_native_password;
  • Comment bind-address, remote login;