CENTOS7 MySQL database installation and configuration

Source: Internet
Author: User

First, the system environment

The system version after the Yum update upgrade is

Second, MySQL installation

Generally, the information given on the Internet is

#yum Install Mysql#yum install Mysql-server#yum install Mysql-devel

Both MySQL and Mysql-devel were installed successfully, but the installation Mysql-server failed with the following:

[email protected] yl]# yum install mysql-serverloaded plugins:fastestmirrorloading mirror speeds from cached Hostfile * base:mirrors.sina.cn * extras:mirrors.sina.cn * updates:mirrors.sina.cnNo package mysql-server available. Error:nothing to do

The data found that the CentOS 7 version removed the MySQL database software from the default program list and replaced it with MARIADB.

There are two ways to solve this problem:

1, method one: Install MARIADB

MARIADB database management System is a branch of MySQL, mainly by the open source community in the maintenance, the use of GPL license. One of the reasons for developing this branch is that after Oracle acquired MySQL, there is a potential risk of shutting MySQL out of the source, so the community uses a branching approach to avoid this risk. MARIADB is designed to be fully compatible with MySQL, including APIs and command lines, making it easy to be a replacement for MySQL.

Install MARIADB, size M.

The relevant commands for the MARIADB database are:

Systemctl Start mariadb #启动MariaDB

Systemctl Stop mariadb #停止MariaDB

Systemctl Restart MARIADB #重启MariaDB

Systemctl Enable MARIADB #设置开机启动

So start the database first

[Email protected] yl]# systemctl start mariadb

And then you can use MySQL as usual.

[Email protected] yl]# mysql-u root-penter password:welcome to the MariaDB Monitor.  Commands End With; MariaDB Connection ID is 3Server version:5.5.41-mariadb MariaDB servercopyright (c) \g.your, Oracle, Mariad B 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               

After installing MariaDB is also MariaDB [(none)]>, may seem a bit unaccustomed. Here is the second method.

2, Method two: official website download installs Mysql-server
# 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

Restart the MySQL service after the installation is successful.

# Service Mysqld Restart

The initial installation of the Mysql,root account has no password.

[Email protected] yl]# mysql-u root Welcome to the MySQL monitor.  Commands End With; or \g.your MySQL connection ID is 3Server version:5.6.26 mysql Community Server (GPL) Copyright (c), Oracle and /or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema | | mysql              | | performance_schema | | test               

Set Password

You do not need to restart the database to take effect.

During the MySQL installation process, the following content:

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 automatically replaced, will no longer take effect.

Third, configuration mysql1, encoding

MySQL config file is/etc/my.cnf

Finally add the encoding configuration

[Mysql]default-character-set =utf8

The character encoding here must be consistent with the/usr/share/mysql/charsets/index.xml.

2. Remote connection Settings

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

Mysql> Grant all privileges on * * to [e-mail protected] '% ' identified by ' password ';

If you are a new user and not root, create a new user first

Mysql>create user ' username ' @ '% ' identified by ' password ';  

The remote connection is now available.

CENTOS7 MySQL database installation and configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.