Detailed explanation on how to install MySQL database on Alibaba Cloud Server

Detailed explanation on how to install MySQL database on Alibaba Cloud Server

Preface

Since I needed to install Zookeeper during the learning process, my virtual machine always had problems, so I bought an Alibaba Cloud server. After installing zookeeper, I thought about installing the database on the server to relieve the pressure on the computer. I encountered many problems when installing the database. After looking at the works of some big guys, I finally installed the database. Now let me summarize the problems I encountered as follows:

1. Uninstall MySQL

1. Check whether mysql is installed

First check whether it has been installed. If it has been installed, delete the previous version to avoid unsuccessful installation.

[root@localhost ~]# php -v
or [root@localhost ~]# rpm -qa | grep mysql
or [root@localhost ~]# yum list installed | grep mysql

If the following is displayed, it means that the service is not installed

-bash: gerp: command not found

If yes, it will be displayed as follows:

mysql57-community-release-el7-8.noarch
mysql-community-common-5.1.73-1.el7.x86_64
mysql-community-client-5.1.73-1.el7.x86_64
mysql-community-server-5.1.73-1.el7.x86_64
mysql-community-libs-5.1.73-1.el7.x86_64
mysql-community-libs-compat-5.1.73-1.el7.x86_64

At this time, you need to uninstall these installation services

[root@localhost ~]# rpm -e mysql57-community-release-el7-8.noarch
[root@localhost ~]# rpm -e mysql-community-common-5.1.73-1.el7.x86_64
[root@localhost ~]# rpm -e mysql-community-client-5.1.73-1.el7.x86_64
[root@localhost ~]# rpm -e mysql-community-server-5.1.73-1.el7.x86_64
[root@localhost ~]# rpm -e mmysql-community-libs-5.1.73-1.el7.x86_64
[root@localhost ~]# rpm -e mysql-community-libs-compat-5.1.73-1.el7.x86_64

2. Delete the configured mysql space

First check the datadir configured in my.cnf to avoid deleting the wrong file (default: /var/lib/mysql)

Delete datadir

rm -rf /var/lib/mysql/

Deleting a Configuration

rm /etc/my.cnf

3. Check the remaining mysql information

whereis mysql

For example, I have the following information

mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

Delete all the mysqls found

View mysql dependencies

systemctl list-dependencies mysqld

If it shows only

mysqld.service

It’s now deleted!

If it shows like this, you have to continue deleting

mysqld.service
● ├─system.slice
● └─basic.target
● ├─microcode.service
● ├─rhel-dmesg.service
● ├─[email protected]
● ├─paths.target
● ├─slices.target
● │ ├─-.slice
● │ └─system.slice
● ├─sockets.target
● │ ├─dbus.socket
● │ ├─systemd-initctl.socket
● │ ├─systemd-journald.socket
● │ ├─systemd-shutdownd.socket
● │ ├─systemd-udevd-control.socket
● │ └─systemd-udevd-kernel.socket
● ├─sysinit.target
● │ ├─dev-hugepages.mount
● │ ├─dev-mqueue.mount
● │ ├─kmod-static-nodes.service
● │ ├─plymouth-read-write.service
● │ ├─plymouth-start.service
● │ ├─proc-sys-fs-binfmt_misc.automount
● │ ├─rhel-autorelabel-mark.service
● │ ├─rhel-autorelabel.service
● │ ├─rhel-domainname.service
● │ ├─rhel-import-state.service
● │ ├─rhel-loadmodules.service
● │ ├─sys-fs-fuse-connections.mount
● │ ├─sys-kernel-config.mount
● │ ├─sys-kernel-debug.mount

4.MySQL uninstallation is complete. After completing the above steps, the uninstallation is finally complete!

2. Install MySQL

1. Make sure the server system is up to date

[root@localhost ~]# yum -y update

If the displayed content contains

[root@localhost ~]# Complete!

Description Update completed

2. Restart the server (optional)

[root@localhost ~]# reboot

3. Download the MySql installation package

[root@localhost ~]# rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
or [root@localhost ~]# rpm -ivh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

4. Install MySql

[root@localhost ~]# yum install -y mysql-server
or [root@localhost ~]# yum install mysql-community-server

If the following is displayed, the installation is successful

Complete!

5. Modify the MySQL default character set

Here we need to set it to utf8, open the my.cnf configuration file

vi /etc/my.cnf

Add the following content:

//Add the server character set character-set-server=utf8 under [mysqld]
collation-server=utf8_general_ci

//You need to fill in the client character set [client] at the bottom
default-character-set=utf8

6. Set up Mysql to start at boot

[root@localhost ~]# systemctl enable mysqld.service

Check whether the automatic startup setting is successful

[root@localhost ~]# systemctl list-unit-files | grep mysqld

If the following content is displayed, the automatic startup installation has been completed

mysqld.service enabled

7. Set up the service

[root@localhost ~]# systemctl start mysqld.service
or [root@localhost ~]# service mysqld start

8. View the default password of MySql

Get the original password directly

[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log

View log acquisition

[root@localhost ~]# cat /var/log/mysqld.log

The initial password is after root@localhost:

9. Log in to MySql and enter your username and password

[root@localhost ~]# mysql -uroot -p

However, the login failed when using the original password!

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Here you need to configure rules in the instance security group to open port 3306

10. Change the mysql login password

Set the password validation strength level and set the global parameter validate_password_policy to LOW

set global validate_password_policy=LOW;

The current password length is 8, and we usually set it to a 6-digit password.

 set global validate_password_length=6;

Set the MySQL password as long as it is six characters long.

alter user 'root'@'localhost' identified by '123456';

11. Grant remote connection permissions

//Authorize grant all privileges on *.* to 'root' @'%' identified by 'password';
//Flush privileges;

12. Turn off the Linux system firewall

systemctl stop firewalld.service

Summarize

I thought installing the database this time would be a very simple matter, but I encountered many problems and tried many MySQL versions. What I still remember vividly was the failure to start MySQL after the installation was completed, which resulted in the inability to complete the subsequent configuration of MySQL. Finally, I consulted Alibaba Cloud after-sales engineers and consulted some documents to solve the problems I encountered. I would like to record this!

This is the end of this article on how to install MySQL database on Alibaba Cloud Server. For more information about installing MySQL on Alibaba Cloud, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed process of setting up Php+Apache operating environment on Alibaba Cloud Server
  • Installing Alibaba Cloud Server with Docker and the pitfalls encountered in installing it in a virtual machine (summary of problems)
  • Detailed tutorial for installing oracle19c on cloud server centos8
  • Detailed tutorial on installing Tomcat8.5 in Centos8.2 cloud server environment
  • Detailed tutorial on installing MySQL database on Alibaba Cloud Server
  • Alibaba Cloud Server Tomcat cannot be accessed
  • How to open port 8080 on Alibaba Cloud ECS server
  • A brief discussion on how to choose an operating system for a cloud server

<<:  Implementation of form submission in html

>>:  Comprehensive summary of Vue3.0's various listening methods

Recommend

Let IE6, IE7, IE8 support CSS3 rounded corners and shadow styles

I want to make a page using CSS3 rounded corners ...

Several ways to encapsulate breadcrumb function components in Vue3

Table of contents Preface 1. Why do we need bread...

How to Install Oracle Java 14 on Ubuntu Linux

Recently, Oracle announced the public availabilit...

Summary of Textarea line break issues in HTML

Recently, I encountered a problem of whether the d...

Several common CSS layouts (summary)

Summary This article will introduce the following...

Detailed explanation of the solution to image deformation under flex layout

Flex layout is a commonly used layout method nowa...

mysql8.0.11 winx64 manual installation and configuration tutorial

First of all, let me talk to you about my daily l...

Linux system repair mode (single user mode)

Table of contents Preface 1. Common bug fixes in ...

A Brief Analysis of the Differences between “:=” and “=” in MySQL

= Only when setting and updating does it have the...

Introduction to building a DNS server under centos7

Table of contents 1. Project environment: 2: DNS ...

Summary of solutions to common Linux problems

1. Connect Centos7 under VMware and set a fixed I...

Detailed example of creating and deleting tables in MySQL

The table creation command requires: The name of...