CentOS 7 Database (MariaDB)

Loading

從 CentOS 7 開始的 Database 都換成了 MariaDB,主要的原因是 MySQL 被甲骨文 (Oracle) 收購 (MySQL 原本是屬於昇陽電腦 SUN ),MySQL 社群擔心甲骨文對於 MySQL 這個開放軟體未來的態度,所以

Michael Widenius ( MySQL 創辦人) 推出了與 MySQL 相容的 MariaDB (MariaDB 與 MySQL 資料庫是相容的)

測試環境為 CentOS 7 x86_64 (虛擬機)

雖然指令是安裝 MySQL 但其實卻是安裝成 MariaDB (也可以直接用 #yum install mariadb mariadb-devel)

[root@localhost ~]# yum update
[root@localhost ~]# yum install mysql
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.stu.edu.tw
 * extras: ftp.stu.edu.tw
 * updates: ftp.stu.edu.tw
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.50-1.el7_2 will be installed
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.50-1.el7_2 for package: 1:mariadb-5.5.50-1.el7_2.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.47-1.el7_2 will be updated
---> Package mariadb-libs.x86_64 1:5.5.50-1.el7_2 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch          Version                 Repository      Size
================================================================================
Installing:
 mariadb             x86_64        1:5.5.50-1.el7_2        updates        8.9 M
Updating for dependencies:
 mariadb-libs        x86_64        1:5.5.50-1.el7_2        updates        755 k

Transaction Summary
================================================================================
Install  1 Package
Upgrade             ( 1 Dependent package)

Total download size: 9.7 M
Is this ok [y/d/N]: y
Downloading packages:
mariadb.x86_64 1:5.5.50-1.el7_2
mariadb-libs.x86_64 1:5.5.50-1.el7_2
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : 1:mariadb-libs-5.5.50-1.el7_2.x86_64                         1/3
  Installing : 1:mariadb-5.5.50-1.el7_2.x86_64                              2/3
  Cleanup    : 1:mariadb-libs-5.5.47-1.el7_2.x86_64                         3/3
  Verifying  : 1:mariadb-libs-5.5.50-1.el7_2.x86_64                         1/3
  Verifying  : 1:mariadb-5.5.50-1.el7_2.x86_64                              2/3
  Verifying  : 1:mariadb-libs-5.5.47-1.el7_2.x86_64                         3/3

Installed:
  mariadb.x86_64 1:5.5.50-1.el7_2

Dependency Updated:
  mariadb-libs.x86_64 1:5.5.50-1.el7_2

Complete!
[root@localhost ~]# yum install mysql-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.stu.edu.tw
 * extras: ftp.stu.edu.tw
 * updates: ftp.stu.edu.tw
Resolving Dependencies
--> Running transaction check
---> Package mariadb-devel.x86_64 1:5.5.50-1.el7_2 will be installed
--> Processing Dependency: openssl-devel(x86-64) for package: 1:mariadb-devel-5.5.50-1.el7_2.x86_64
--> Running transaction check
---> Package openssl-devel.x86_64 1:1.0.1e-51.el7_2.5 will be installed
--> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.1e-51.el7_2.5.x86_64
--> Running transaction check
---> Package krb5-devel.x86_64 0:1.13.2-12.el7_2 will be installed
--> Processing Dependency: libverto-devel for package: krb5-devel-1.13.2-12.el7_2.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.13.2-12.el7_2.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.13.2-12.el7_2.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.13.2-12.el7_2.x86_64
--> Running transaction check
---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed
---> Package libcom_err-devel.x86_64 0:1.42.9-7.el7 will be installed
---> Package libselinux-devel.x86_64 0:2.2.2-6.el7 will be installed
--> Processing Dependency: libsepol-devel >= 2.1.9-1 for package: libselinux-devel-2.2.2-6.el7.x86_64
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.2.2-6.el7.x86_64
--> Processing Dependency: pkgconfig(libpcre) for package: libselinux-devel-2.2.2-6.el7.x86_64
---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed
--> Running transaction check
---> Package libsepol-devel.x86_64 0:2.1.9-3.el7 will be installed
---> Package pcre-devel.x86_64 0:8.32-15.el7_2.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                 Arch       Version                   Repository   Size
================================================================================
Installing:
 mariadb-devel           x86_64     1:5.5.50-1.el7_2          updates     750 k
Installing for dependencies:
 keyutils-libs-devel     x86_64     1.5.8-3.el7               base         37 k
 krb5-devel              x86_64     1.13.2-12.el7_2           updates     649 k
 libcom_err-devel        x86_64     1.42.9-7.el7              base         30 k
 libselinux-devel        x86_64     2.2.2-6.el7               base        174 k
 libsepol-devel          x86_64     2.1.9-3.el7               base         71 k
 libverto-devel          x86_64     0.2.5-4.el7               base         12 k
 openssl-devel           x86_64     1:1.0.1e-51.el7_2.5       updates     1.2 M
 pcre-devel              x86_64     8.32-15.el7_2.1           updates     479 k

Transaction Summary
================================================================================
Install  1 Package (+8 Dependent packages)

Total download size: 3.3 M
Installed size: 8.9 M
Is this ok [y/d/N]: y
Downloading packages:
(1/9): libsepol-devel-2.1.9-3.el7.x86_64.rpm               |  71 kB   00:02
(2/9): libselinux-devel-2.2.2-6.el7.x86_64.rpm             | 174 kB   00:03
(3/9): krb5-devel-1.13.2-12.el7_2.x86_64.rpm               | 649 kB   00:04
(4/9): libcom_err-devel-1.42.9-7.el7.x86_64.rpm            |  30 kB   00:04
(5/9): libverto-devel-0.2.5-4.el7.x86_64.rpm               |  12 kB   00:00
(6/9): mariadb-devel-5.5.50-1.el7_2.x86_64.rpm             | 750 kB   00:01
(7/9): openssl-devel-1.0.1e-51.el7_2.5.x86_64.rpm          | 1.2 MB   00:02
(8/9): pcre-devel-8.32-15.el7_2.1.x86_64.rpm               | 479 kB   00:04
(9/9): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm          |  37 kB   00:09
--------------------------------------------------------------------------------
Total                                              345 kB/s | 3.3 MB  00:09
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libcom_err-devel-1.42.9-7.el7.x86_64                         1/9
  Installing : pcre-devel-8.32-15.el7_2.1.x86_64                            2/9
  Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64                       3/9
  Installing : libsepol-devel-2.1.9-3.el7.x86_64                            4/9
  Installing : libselinux-devel-2.2.2-6.el7.x86_64                          5/9
  Installing : libverto-devel-0.2.5-4.el7.x86_64                            6/9
  Installing : krb5-devel-1.13.2-12.el7_2.x86_64                            7/9
  Installing : 1:openssl-devel-1.0.1e-51.el7_2.5.x86_64                     8/9
  Installing : 1:mariadb-devel-5.5.50-1.el7_2.x86_64                        9/9
  Verifying  : 1:mariadb-devel-5.5.50-1.el7_2.x86_64                        1/9
  Verifying  : libselinux-devel-2.2.2-6.el7.x86_64                          2/9
  Verifying  : libverto-devel-0.2.5-4.el7.x86_64                            3/9
  Verifying  : libsepol-devel-2.1.9-3.el7.x86_64                            4/9
  Verifying  : keyutils-libs-devel-1.5.8-3.el7.x86_64                       5/9
  Verifying  : pcre-devel-8.32-15.el7_2.1.x86_64                            6/9
  Verifying  : 1:openssl-devel-1.0.1e-51.el7_2.5.x86_64                     7/9
  Verifying  : libcom_err-devel-1.42.9-7.el7.x86_64                         8/9
  Verifying  : krb5-devel-1.13.2-12.el7_2.x86_64                            9/9

Installed:
  mariadb-devel.x86_64 1:5.5.50-1.el7_2

Dependency Installed:
  keyutils-libs-devel.x86_64 0:1.5.8-3.el7
  krb5-devel.x86_64 0:1.13.2-12.el7_2
  libcom_err-devel.x86_64 0:1.42.9-7.el7
  libselinux-devel.x86_64 0:2.2.2-6.el7
  libsepol-devel.x86_64 0:2.1.9-3.el7
  libverto-devel.x86_64 0:0.2.5-4.el7
  openssl-devel.x86_64 1:1.0.1e-51.el7_2.5
  pcre-devel.x86_64 0:8.32-15.el7_2.1

Complete!

mysql-server 也不提供了,需要安裝 mariadb-server , mariadb 套件.

[root@localhost ~]# yum install mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.stu.edu.tw
 * extras: ftp.stu.edu.tw
 * updates: ftp.stu.edu.tw
No package mysql-server available.
Error: Nothing to do
[root@localhost ~]# yum install mariadb-server mariadb
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.stu.edu.tw
 * extras: ftp.stu.edu.tw
 * updates: ftp.stu.edu.tw
Package 1:mariadb-5.5.50-1.el7_2.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package mariadb-server.x86_64 1:5.5.50-1.el7_2 will be installed
--> Processing Dependency: perl-DBI for package: 1:mariadb-server-5.5.50-1.el7_2.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.50-1.el7_2.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: 1:mariadb-server-5.5.50-1.el7_2.x86_64
--> Processing Dependency: perl(DBI) for package: 1:mariadb-server-5.5.50-1.el7_2.x86_64
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:4.023-5.el7 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
--> Running transaction check
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                     Arch       Version               Repository   Size
================================================================================
Installing:
 mariadb-server              x86_64     1:5.5.50-1.el7_2      updates      11 M
Installing for dependencies:
 perl-Compress-Raw-Bzip2     x86_64     2.061-3.el7           base         32 k
 perl-Compress-Raw-Zlib      x86_64     1:2.061-4.el7         base         57 k
 perl-DBD-MySQL              x86_64     4.023-5.el7           base        140 k
 perl-DBI                    x86_64     1.627-4.el7           base        802 k
 perl-Data-Dumper            x86_64     2.145-3.el7           base         47 k
 perl-IO-Compress            noarch     2.061-2.el7           base        260 k
 perl-Net-Daemon             noarch     0.48-5.el7            base         51 k
 perl-PlRPC                  noarch     0.2020-14.el7         base         36 k

Transaction Summary
================================================================================
Install  1 Package (+8 Dependent packages)

Total download size: 12 M
Installed size: 59 M
Is this ok [y/d/N]: y
Downloading packages:
mariadb-server-5.5.50-1.el7_2. FAILED
http://centos.cs.nctu.edu.tw/7.2.1511/updates/x86_64/Packages/mariadb-server-5.5.50-1.el7_2.x86_64.rpm: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below knowledge base article

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/

(1/9): perl-Data-Dumper-2.145-3.el7.x86_64.rpm             |  47 kB   00:00
(2/9): perl-DBI-1.627-4.el7.x86_64.rpm                     | 802 kB   00:03
(3/9): perl-Net-Daemon-0.48-5.el7.noarch.rpm               |  51 kB   00:00
(4/9): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm       |  57 kB   00:04
(5/9): perl-PlRPC-0.2020-14.el7.noarch.rpm                 |  36 kB   00:00
(6/9): perl-DBD-MySQL-4.023-5.el7.x86_64.rpm               | 140 kB   00:05
(7/9): perl-IO-Compress-2.061-2.el7.noarch.rpm             | 260 kB   00:05
(8/9): mariadb-server-5.5.50-1.el7_2.x86_64.rpm            |  11 MB   00:08
(9/9): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm      |  32 kB   00:14
--------------------------------------------------------------------------------
Total                                              832 kB/s |  12 MB  00:14
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : perl-Data-Dumper-2.145-3.el7.x86_64                          1/9
  Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                  2/9
  Installing : perl-Net-Daemon-0.48-5.el7.noarch                            3/9
  Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                   4/9
  Installing : perl-IO-Compress-2.061-2.el7.noarch                          5/9
  Installing : perl-PlRPC-0.2020-14.el7.noarch                              6/9
  Installing : perl-DBI-1.627-4.el7.x86_64                                  7/9
  Installing : perl-DBD-MySQL-4.023-5.el7.x86_64                            8/9
  Installing : 1:mariadb-server-5.5.50-1.el7_2.x86_64                       9/9
  Verifying  : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                   1/9
  Verifying  : perl-Net-Daemon-0.48-5.el7.noarch                            2/9
  Verifying  : 1:mariadb-server-5.5.50-1.el7_2.x86_64                       3/9
  Verifying  : perl-Data-Dumper-2.145-3.el7.x86_64                          4/9
  Verifying  : perl-PlRPC-0.2020-14.el7.noarch                              5/9
  Verifying  : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                  6/9
  Verifying  : perl-DBI-1.627-4.el7.x86_64                                  7/9
  Verifying  : perl-IO-Compress-2.061-2.el7.noarch                          8/9
  Verifying  : perl-DBD-MySQL-4.023-5.el7.x86_64                            9/9

Installed:
  mariadb-server.x86_64 1:5.5.50-1.el7_2

Dependency Installed:
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7
  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
  perl-DBD-MySQL.x86_64 0:4.023-5.el7
  perl-DBI.x86_64 0:1.627-4.el7
  perl-Data-Dumper.x86_64 0:2.145-3.el7
  perl-IO-Compress.noarch 0:2.061-2.el7
  perl-Net-Daemon.noarch 0:0.48-5.el7
  perl-PlRPC.noarch 0:0.2020-14.el7

Complete!

服務也變成 MariaDB 了.

[root@localhost ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since 四 2018-05-03 04:01:29 EDT; 2s ago
  Process: 2127 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 2046 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 2126 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─2126 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─2288 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql...
[root@localhost ~]# systemctl status mysql
● mysql.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

如果是要將 MySQL 資料庫資料轉成 MariaDB 了.轉換方式可以參考 https://benjr.tw/95587

設定一下 MariaDB

[root@localhost ~]$ mysql_secure_installation
 
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] n
 ... skipping.
 
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!

剛剛就已經設定了 MariaDB root 密碼.登入看看.

[root@localhost ~]$ mysql -u root -p 
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
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 |
+--------------------+
3 rows in set (0.01 sec)
 
MariaDB [(none)]> exit;
Bye
沒有解決問題,試試搜尋本站其他內容

One thought on “CentOS 7 Database (MariaDB)

  1. 自動引用通知: CentOS 7 + wordpress – Benjr.tw

發佈留言

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

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料