Detailed tutorial on installing MySQL database on Alibaba Cloud Server

Detailed tutorial on installing 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 uninstall completed

After completing the above steps, the uninstall 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. Modify the MySQL login password and set the password verification strength level. Set the global parameter of 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 about the detailed tutorial on how to install MySQL database on Alibaba Cloud Server. For more information about how to install MySQL database on Alibaba Cloud Server, 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 explanation on how to install 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

<<:  JS 4 super practical tips to improve development efficiency

>>:  8 JS reduce usage examples and reduce operation methods

Recommend

Calling the search engine in the page takes Baidu as an example

Today, it suddenly occurred to me that it would be...

Rhit efficient visualization Nginx log viewing tool

Table of contents Introduction Install Display Fi...

Which one should I choose between MySQL unique index and normal index?

Imagine a scenario where, when designing a user t...

SQL Server Comment Shortcut Key Operation

Batch comments in SQL Server Batch Annotation Ctr...

Nginx stream configuration proxy (Nginx TCP/UDP load balancing)

Prelude We all know that nginx is an excellent re...

Use shell script to install python3.8 environment in CentOS7 (recommended)

One-click execution To install Python 3.8 in a vi...

Vue realizes click flip effect

Use vue to simply implement a click flip effect f...

Vue v-model related knowledge summary

​v-model is a Vue directive that provides two-way...

Analysis of the cause of docker error Exited (1) 4 minutes ago

Docker error 1. Check the cause docker logs nexus...

Summary of ways to implement single sign-on in Vue

The project has been suspended recently, and the ...

Usage and scenario analysis of npx command in Node.js

npx usage tutorial Tonight, when I was learning V...