centos install Mariadb 10.3

Posted in :

在匯出 mysql 5.7 的 database 到 mariadb 5.5 時遇到很多相容性的問題,例如:

COLLATE utf8mb4_unicode_520_ci

STATS_PERSISTENT=0

這些在 mysql 5.7 有的參數,在 mariadb 5.5 沒有,無法匯入database, 把 centos 上的 mariadb 升到 10.3 還是一樣,不支援

utf8mb4_unicode_520_ci,但是從 mariadb 官方文件來看,這又是應該支援的:

https://mariadb.com/kb/en/library/supported-character-sets-and-collations/

暫時先把 COLLATE 拿掉,使用database default value 就 OK了。

 

在 centOS 7.0 上安裝 mariadb 10.3, 步驟如下:


MariaDB 10.3 stable version has been released on Oct 09, 2017. It is an enhanced, drop-in replacement for MySQL. MariaDB can be an better choice for choice for database professionals looking for a robustscalable, and reliable SQL server. MariaDB has a number of updated features over MySQL. Use below links to read features comparison between MariaDB and MySQL. This article will help you to install MariaDB 10.3 in CentOS, RHEL 7/6 and Fedora Fedora 26/25/24 systems using yum.

Step 1: Add MariaDB Yum Repositories

First add MariaDB yum repository in our system. Create a new repo file /etc/yum.repos.d/mariadb.repo in your system and add below code as per your operating system and architecture.

For CentOS/RHEL – 7

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/rhel7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

For CentOS/RHEL – 6

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/rhel6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

For Fedora – 26 / 25 / 24

Please change version (red highlighted) in below setting as per version of Fedora you used. Click here To view all available repositories.

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/fedora26-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Step 2 – Install MariaDB Server

Let’s use the following command to install MariaDB 10.2 in your system. This will also installed other dependencies automatically.

# yum install MariaDB-server MariaDB-client

After installing MariaDB in your system start it’s service using the following command.

## CentOS/Redhat 7, Fedora 26/25 
# systemctl start mysql.service

## CentOS/Redhat 6 
# service mysql start

Step 3 – Secure MariaDB Install

You also need to secure your MariaDB installation using passwords and do some other changes. To do this run secure installation script from command line.

# /usr/bin/mysql_secure_installation

The secure installation script will ask for user input as some points, follow the installation as per below output showing, All user inputs are highlighted with red color.

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Step 4 – Working with MariaDB

After installing and completing the configuration, connect to MariaDB server using the following command.

# mysql -u root -p

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.3.2-MariaDB MariaDB Server

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

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

MariaDB [(none)]>

Also try to create a new database, user and assign privileges to a database.

You may also required install phpMyAdmin to manage MariaDB using web interface, which provides easy way to work.

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *