Centos7 mysql database installation and configuration

1. System environment#

The system version after yum update upgrade is

[ root@yl-web yl]# cat /etc/redhat-release 
CentOS Linux release 7.1.1503(Core)

Two, mysql installation#

Generally, the information given on the Internet is

# yum install mysql
# yum install mysql-server
# yum install mysql-devel

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

[ root@yl-web yl]# yum install mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.sina.cn
 * extras: mirrors.sina.cn
 * updates: mirrors.sina.cn
No package mysql-server available.
Error: Nothing to do

Checking the information found that the CentOS 7 version removed the MySQL database software from the default program list and replaced it with mariadb.

There are two solutions:

1、 Method 1: Install mariadb

The MariaDB database management system is a branch of MySQL, which is mainly maintained by the open source community and is licensed under GPL. One of the reasons for the development of this branch is that after Oracle acquired MySQL, there is a potential risk of closing MySQL to the source, so the community uses branching to avoid this risk. 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.

Install mariadb, size 59 M.

[ root@yl-web yl]# yum install mariadb-server mariadb 

The related commands of the mariadb database are:

systemctl start mariadb #Start MariaDB

systemctl stop mariadb #Stop MariaDB

systemctl restart mariadb #Restart MariaDB

systemctl enable mariadb #Set boot up

So start the database first

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

Then you can use mysql normally

[ root@yl-web yl]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with; or \g.
Your MariaDB connection id is 3
Server version:5.5.41-MariaDB MariaDB Server

Copyright(c)2000,2014, 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 inset(0.00 sec)

MariaDB [(none)]>

MariaDB [(none)]> is displayed after installing mariadb, which may seem a bit unaccustomed. Here is the second method.

2、 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 the installation is successful, restart the mysql service.

# service mysqld restart

When mysql is installed for the first time, the root account has no password.

[ root@yl-web yl]# 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 inset(0.01 sec)

mysql>

set password

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

mysql>

No need to restart the database to take effect.

The following content during the mysql installation:

Installed:
 mysql-community-client.x86_64 0:5.6.26-2.el7                mysql-community-devel.x86_64 0:5.6.26-2.el7                
 mysql-community-libs.x86_64 0:5.6.26-2.el7                  mysql-community-server.x86_64 0:5.6.26-2.el7               

Dependency Installed:
 mysql-community-common.x86_64 0:5.6.26-2.el7                                                                            

Replaced:
 mariadb.x86_64 1:5.5.41-2.el7_0          mariadb-devel.x86_64 1:5.5.41-2.el7_0   mariadb-libs.x86_64 1:5.5.41-2.el7_0  
 mariadb-server.x86_64 1:5.5.41-2.el7_0  

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

[ root@yl-web yl]# rpm -qa |grep mariadb
[ root@yl-web yl]# 

Three, configure mysql

1、 coding##

The mysql configuration file is /etc/my.cnf

Finally add the encoding configuration

[ mysql]default-character-set=utf8

The character encoding here must be the same as in /usr/share/mysql/charsets/Index.xml.

2、 Remote connection settings##

Assign all permissions of all tables in all databases to the root user at all IP addresses.

mysql> grant all privileges on *.* to root@'%'identified by 'password';

If it is a new user instead of root, you must first create a new user

mysql>create user 'tanggao'@'localhost' identified by 'tanggao';

At this point, you can connect remotely.

Recommended Posts

Centos7 mysql database installation and configuration
Centos mysql installation and configuration
Mysql8.0.15 installation configuration (centos7)
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
CentOS 7 installation and configuration PPTP
CentOS installation and configuration cmake
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
Centos7 hadoop cluster installation and configuration
Java-JDK installation and configuration under CentOS
CentOS 7 Tomcat service installation and configuration
CentOS NTP server installation and configuration
Centos MySQL8 configuration
CentOS 7 system installation and configuration graphic tutorial
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
Installation and configuration of redis under centos7
Centos7 hive stand-alone mode installation and configuration
OpenMPI-Ubuntu installation and configuration
Centos7 install Mysql database
Installation and configuration of JDK in CentOS 7 system
CentOS 7 installation and configuration graphic tutorials under VMware10
Installation and configuration of rsync server under CentOS 6.5
Installation and configuration of CentOS 7 in VMware Workstation
Ubuntu16.04 installation and simple configuration
CentOS mysql configuration master-slave replication
CentOS7 postgresql installation and use
Ubuntu PostgreSQL installation and configuration
Centos7 elk7.1.1 installation and use
Environment configuration of JDK, mysql and tomcat under Centos7
CentOS7 yum install and start mysql
CentOS Yum compile and install MySQL 5.6
CentOS 8 install Git and basic configuration
Centos7 installation of Dameng database tutorial
CentOS7 installation and maintenance of Gitlab
CentOS7.2 and Nginx configuration virtual host
CentOS7 yum install and start mysql
Centos7 and centos8 install mysql5.6 5.7 8.0 so simple
CentOS 7.X system installation and optimization
Centos 7 RAID 5 detailed explanation and configuration
Ubuntu 19.1 installation and configuration Chinese environment
The latest Centos7 installation Mysql8 guide
Introduction to CentOS7 installation process of openjdk, tomcat and mysql
Configuration and beautification after Ubuntu installation (1)
2019-07-09 CentOS7 installation
centos7_1708 installation
Nginx installation and configuration load (ubuntu12.04)
CentOs7 installation and deployment Zabbix3.4 original
Erlang 20.2 installation and deployment under CentOS 7
Ubuntu configuration source and installation software
[Switch] CentOS7 64-bit installation mysql tutorial
Centos7.5 configuration java environment installation tomcat explanation
Linux kernel compilation and CentOS system installation
CentOS7.5 source code compile and install mysql5.7.29
Centos7.6 operating system installation and optimization record
Centos7 installation and deployment of gitlab server
Centos7 compile and install MySQL8 problem record
CentOS container installation in Docker uses MySQL
Centos python3 compile installation and compile gcc upgrade
Zabbix installation and deployment and localization under CentOS
CentOS7 installation zabbix 4.0 tutorial (graphics and text)