MySQL installation and configuration method graphic tutorial (CentOS7)

MySQL installation and configuration method graphic tutorial (CentOS7)

1. System environment

[root@localhost home]# cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

2. MySQL installation

The installation of mysql and mysql-devel was successful, but the installation of mysql-server failed, as follows:

[root@localhost home]# yum install mysql-server
 Loaded plugins: fastestmirror, langpacks
 Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
 base | 3.6 kB 00:00:00 
 extras | 3.4 kB 00:00:00 
 updates | 3.4 kB 00:00:00 
 (1/4): base/7/x86_64/group_gz | 155 kB 00:00:01 
 (2/4): extras/7/x86_64/primary_db | 139 kB 00:00:01 
 (3/4): base/7/x86_64/primary_db | 5.6 MB 00:00:38 
 (4/4): updates/7/x86_64/primary_db | 4.7 MB 00:00:39 
 Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
 No package mysql-server available.
 Error: No action required

This problem occurs because the CentOS 7 version removes the MySQL database software from the default program list and replaces it with mariadb

There are two solutions:

Method 1 : Install mariadb

MariaDB database management system is a branch of MySQL. It adopts GPL license. The purpose of MariaDB is to be fully compatible with MySQL, including API and command line, so that it can easily become a substitute for MySQL. MariaDB was developed by Michael Widenius, the founder of MySQL. He had previously sold his company MySQL AB to SUN. After that, with SUN being acquired by Oracle, the ownership of MySQL also fell into the hands of Oracle. MariaDB is named after Michael Widenius' daughter Maria.

Install mariadb, enter the installation command

[root@localhost home]# yum install mariadb-server mariadb

The relevant commands for the mariadb database are:

 systemctl start mariadb #Start MariaDB
 systemctl stop mariadb #Stop MariaDB
 systemctl restart mariadb #Restart MariaDB
 systemctl enable mariadb #Set boot startup

Start the database first

[root@yl-web yl]# systemctl start mariadb

No password by default

[root@localhost lzh]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
|mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.01 sec)

Method 2: Download and install mysql-server from the official website

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server

After successful installation, restart the mysql service

# service mysqld restart

When installing MySQL for the first time, the root account has no password

[root@localhost lzh]# mysql -u root 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
|mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.01 sec)

Set password

mysql> set password for 'root'@'localhost' =password('password');
Query OK, 0 rows affected (0.00 sec)

After installation, mariadb is automatically replaced and will no longer take effect.

[root@localhost lzh]# rpm -qa |grep mariadb

Wonderful topic sharing: Installation tutorials for different versions of MySQL Installation tutorials for MySQL 5.7 versions Installation tutorials for MySQL 5.6 versions

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed steps to send emails using triggers in SQL Server
  • Some methods to optimize query speed when MySQL processes massive data
  • Summary of common optimization operations of MySQL database (experience sharing)
  • Detailed explanation of the use of Join in Mysql
  • MySQL 5.7 installation MySQL service cannot be started but the service does not report any errors
  • SQL Get all the implementation methods of the parent

<<:  Linux method example to view all information of the process

>>:  In-depth explanation of closure in JavaScript

Recommend

How to get the height of MySQL innodb B+tree

Preface The reason why MySQL's innodb engine ...

Two ways to reset the root password of MySQL database using lnmp

The first method: Use Junge's one-click scrip...

Vue custom optional time calendar component

This article example shares the specific code of ...

Mini Program Recording Function Implementation

Preface In the process of developing a mini progr...

Several ways to center a box in Web development

1. Record several methods of centering the box: 1...

Detailed explanation of Vue router routing guard

Table of contents 1. Global beforeEach 1. Global ...

HTML image img tag_Powernode Java Academy

summary Project description format <img src=&q...

Execute the shell or program inside the Docker container on the host

In order to avoid repeatedly entering the Docker ...

Vue implements start time and end time range query

This article shares with you how to query the sta...

Detailed explanation of Linux server status and performance related commands

Server Status Analysis View Linux server CPU deta...

Two solutions for Vue package upload server refresh 404 problem

1: nginx server solution, modify the .conf config...

How to configure domestic sources in CentOS8 yum/dnf

CentOS 8 changed the software package installatio...

A brief analysis of how to set the initial value of Linux root

Ubuntu does not allow root login by default, so t...