Install mysql8 on Alibaba Cloud ECS server
download link
https://downloads.mysql.com/archives/community/
Official installation documentation
https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html
download dependencies
yum install libaio
Put mysql in the /usr/local/ directory
Put the package mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz in the /usr/local/ directory
cd /usr/local/
unzip mysql
tar -xvf mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz
rename folder
mv mysql-8.0.27-linux-glibc2.12-x86_64 mysql8
create folder
mkdir data
mkdir tmp
Directory Structure
Create user groups with users and passwords
group add mysql
useradd -g mysql mysql
authorized user
chown -R mysql.mysql /usr/local/mysql8/
Edit my.cnf file vi /etc/my.cnf
vi /etc/my.cnf
configuration
[mysqld]
basedir = /usr/local/mysql8
datadir = /usr/local/mysql8/data
port = 3306
socket = /usr/local/mysql8/tmp/mysql.sock
#required
sql_mode=NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES
[client]
# Set the default port used by the mysql client to connect to the server
port=3306
default-character-set=utf8mb4
socket = /usr/local/mysql8/tmp/mysql.sock
Switch to the mysql bin directory
cd bin
Initialize basic information
./mysqld --initialize --user=mysql
Add mysqld service to the system
Switch to the support-files directory
cp support-files/mysql.server /etc/init.d/mysql.server
Authorize and add services
chmod +x /etc/init.d/mysql.server
chkconfig --add mysql.server
Check if the addition is successful

Add the mysql command to the service
ln -sf /usr/local/mysql8/bin/mysql /usr/bin
start service
service mysql.server start
Log in to mysql mysql -uroot -p password Use the previously randomly generated password
The password I just randomly generated is lrwQR75;ljAL
mysql -uroot -p
change root password
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
flush privileges;
Where 123456 is the new password
switch to mysql library
use mysql;
select host, user, plugin from user;
Modify the remote connection and take effect
update user set host = '%' where user = 'root';
flush privileges;
The plugin is caching_sha2_password, and the remote connection needs to be suffixed with allowPublicKeyRetrieval = true
Ali cloud server configuration security group
remote connection test
create database testdb;
DBeaver connection
Modify the driver property allowPublicKeyRetrieval = true
Common error one:
Missing dependency libaio-devel.x86_64
yum install libaio-devel.x86_64
Common error two:
Without XXX permissions, the mysql installation directory is authorized, and the command read and write permissions are swiped.
https://downloads.mysql.com/archives/community/
1. Installation
Official installation documentation
https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html
download dependencies
yum install libaio
Put mysql in the /usr/local/ directory
Put the package mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz in the /usr/local/ directory
cd /usr/local/
unzip mysql
tar -xvf mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz
rename folder
mv mysql-8.0.27-linux-glibc2.12-x86_64 mysql8
create folder
mkdir data
mkdir tmp
Directory Structure
Create user groups with users and passwords
group add mysql
useradd -g mysql mysql
authorized user
chown -R mysql.mysql /usr/local/mysql8/
Edit my.cnf file vi /etc/my.cnf
vi /etc/my.cnf
configuration
[mysqld]
basedir = /usr/local/mysql8
datadir = /usr/local/mysql8/data
port = 3306
socket = /usr/local/mysql8/tmp/mysql.sock
#required
sql_mode=NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES
[client]
# Set the default port used by the mysql client to connect to the server
port=3306
default-character-set=utf8mb4
socket = /usr/local/mysql8/tmp/mysql.sock
Switch to the mysql bin directory
cd bin
Initialize basic information
./mysqld --initialize --user=mysql
Add mysqld service to the system
Switch to the support-files directory
cp support-files/mysql.server /etc/init.d/mysql.server
Authorize and add services
chmod +x /etc/init.d/mysql.server
chkconfig --add mysql.server
Check if the addition is successful

Add the mysql command to the service
ln -sf /usr/local/mysql8/bin/mysql /usr/bin
start service
service mysql.server start
Log in to mysql mysql -uroot -p password Use the previously randomly generated password
The password I just randomly generated is lrwQR75;ljAL
mysql -uroot -p
change root password
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
flush privileges;
Where 123456 is the new password
switch to mysql library
use mysql;
select host, user, plugin from user;
Modify the remote connection and take effect
update user set host = '%' where user = 'root';
flush privileges;
The plugin is caching_sha2_password, and the remote connection needs to be suffixed with allowPublicKeyRetrieval = true
Ali cloud server configuration security group
remote connection test
create database testdb;
DBeaver connection
Modify the driver property allowPublicKeyRetrieval = true
2. Notes on installation
Common error one:
Missing dependency libaio-devel.x86_64
yum install libaio-devel.x86_64
Common error two:
Without XXX permissions, the mysql installation directory is authorized, and the command read and write permissions are swiped.
Related Articles
-
A detailed explanation of Hadoop core architecture HDFS
Knowledge Base Team
-
What Does IOT Mean
Knowledge Base Team
-
6 Optional Technologies for Data Storage
Knowledge Base Team
-
What Is Blockchain Technology
Knowledge Base Team
Explore More Special Offers
-
Short Message Service(SMS) & Mail Service
50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00