#查看版本 [root@guangzhou local]# mysql --version mysql Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1 #查看使用狀態 [root@guangzhou local]# systemctl status mariadb ● mariadb.service - MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) Active: active (running) since 三 2020-01-29 17:31:33 CST; 6 days ago Main PID: 964 (mysqld_safe) CGroup: /system.slice/mariadb.service ├─ 964 /bin/sh /usr/bin/mysqld_safe --basedir=/usr └─1249 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log -... 1月 29 17:31:29 guangzhou systemd[1]: Starting MariaDB database server... 1月 29 17:31:29 guangzhou mariadb-prepare-db-dir[870]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done. 1月 29 17:31:30 guangzhou mysqld_safe[964]: 200129 17:31:30 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'. 1月 29 17:31:30 guangzhou mysqld_safe[964]: 200129 17:31:30 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 1月 29 17:31:33 guangzhou systemd[1]: Started MariaDB database server. #查看自帶安裝信息 [root@guangzhou local]# rpm -qa | grep -i mariadb mariadb-5.5.64-1.el7.x86_64 mariadb-server-5.5.64-1.el7.x86_64 mariadb-libs-5.5.64-1.el7.x86_64 [root@guangzhou local]# yum list|grep mariadb mariadb.x86_64 1:5.5.64-1.el7 @os mariadb-libs.x86_64 1:5.5.64-1.el7 @os mariadb-server.x86_64 1:5.5.64-1.el7 @os mariadb-bench.x86_64 1:5.5.64-1.el7 os mariadb-devel.i686 1:5.5.64-1.el7 os mariadb-devel.x86_64 1:5.5.64-1.el7 os mariadb-embedded.i686 1:5.5.64-1.el7 os mariadb-embedded.x86_64 1:5.5.64-1.el7 os mariadb-embedded-devel.i686 1:5.5.64-1.el7 os mariadb-embedded-devel.x86_64 1:5.5.64-1.el7 os mariadb-libs.i686 1:5.5.64-1.el7 os mariadb-test.x86_64 1:5.5.64-1.el7 os
#停止服務運行 [root@guangzhou local]# systemctl stop mariadb && systemctl status mariadb ● mariadb.service - MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) Active: inactive (dead) since 三 2020-02-05 10:55:53 CST; 8ms ago Process: 964 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS) Main PID: 964 (code=exited, status=0/SUCCESS) 1月 29 17:31:29 guangzhou systemd[1]: Starting MariaDB database server... 1月 29 17:31:29 guangzhou mariadb-prepare-db-dir[870]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done. 1月 29 17:31:30 guangzhou mysqld_safe[964]: 200129 17:31:30 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'. 1月 29 17:31:30 guangzhou mysqld_safe[964]: 200129 17:31:30 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 1月 29 17:31:33 guangzhou systemd[1]: Started MariaDB database server. 2月 05 10:55:50 guangzhou systemd[1]: Stopping MariaDB database server... 2月 05 10:55:53 guangzhou systemd[1]: Stopped MariaDB database server.
#開始卸載 [root@guangzhou local]# yum remove -y mariadb && yum remove -y mariadb-* ... #已搜不到安裝信息 [root@guangzhou local]# yum list installed |grep mariadb [root@guangzhou local]# rpm -qa|grep mariadb [root@guangzhou local]# find / -name mysql /var/lib/mysql /usr/lib64/mysql [root@guangzhou local]# rm -rf /var/lib/mysql/ [root@guangzhou local]# rm -rf /var/lib64/mysql/ [root@guangzhou local]# find / -name mariadb /var/log/mariadb [root@guangzhou local]# rm -rf /var/log/mariadb
#配置yum源為國內地址 [root@guangzhou local]# vim /etc/yum.repos.d/Mariadb.repo #錄入以下內容 [mariadb] name = MariaDB baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64 gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1 #清除yum源緩存數據,並生成新的yum源數據緩存 [root@guangzhou local]# yum clean all && yum makecache all ... #查看下載緩存信息 [root@guangzhou local]# ll /var/cache/yum/x86_64/7/mariadb 總用量 396 -rw-r--r-- 1 root root 54485 1月 28 02:57 6ee412270ec698aa4df35ba5cce163c7a253cd6421e25227cacc56e2e60c61bd-primary.sqlite.bz2 -rw-r--r-- 1 root root 10337 1月 28 02:57 a72c2fc88cd9a6a39f8eaa8649dae1ce968531dbfdae3a004536c2f1d4a4cfc4-other.sqlite.bz2 -rw-r--r-- 1 root root 0 2月 5 11:18 cachecookie -rw-r--r-- 1 root root 305249 1月 28 02:57 fd747406618f18fd6d25d3589466d78cc3e31d2efcebf39a08da8cb58b80b619-filelists.sqlite.bz2 drwxr-xr-x 2 root root 4096 2月 5 11:19 gen drwxr-xr-x 2 root root 4096 2月 5 11:18 packages -rw-r--r-- 1 root root 2988 1月 28 02:57 repomd.xml
#開始安裝 [root@guangzhou local]# yum install MariaDB-server MariaDB-client -y 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile 正在解決依賴關系 --> 正在檢查事務 ---> 軟件包 MariaDB-client.x86_64.0.10.2.31-1.el7.centos 將被 安裝 --> 正在處理依賴關系 MariaDB-common,它被軟件包 MariaDB-client-10.2.31-1.el7.centos.x86_64 需要 ---> 軟件包 MariaDB-server.x86_64.0.10.2.31-1.el7.centos 將被 安裝 --> 正在處理依賴關系 galera,它被軟件包 MariaDB-server-10.2.31-1.el7.centos.x86_64 需要 --> 正在檢查事務 ---> 軟件包 MariaDB-common.x86_64.0.10.2.31-1.el7.centos 將被 安裝 --> 正在處理依賴關系 MariaDB-compat,它被軟件包 MariaDB-common-10.2.31-1.el7.centos.x86_64 需要 ---> 軟件包 galera.x86_64.0.25.3.28-1.rhel7.el7.centos 將被 安裝 --> 正在處理依賴關系 libboost_program_options.so.1.53.0()(64bit),它被軟件包 galera-25.3.28-1.rhel7.el7.centos.x86_64 需要 --> 正在檢查事務 ---> 軟件包 MariaDB-compat.x86_64.0.10.2.31-1.el7.centos 將被 安裝 ---> 軟件包 boost-program-options.x86_64.0.1.53.0-27.el7 將被 安裝 --> 解決依賴關系完成 依賴關系解決 ================================================================================================================================================================ Package 架構 版本 源 大小 ================================================================================================================================================================ 正在安裝: MariaDB-client x86_64 10.2.31-1.el7.centos mariadb 11 M MariaDB-server x86_64 10.2.31-1.el7.centos mariadb 24 M 為依賴而安裝: MariaDB-common x86_64 10.2.31-1.el7.centos mariadb 81 k MariaDB-compat x86_64 10.2.31-1.el7.centos mariadb 2.8 M boost-program-options x86_64 1.53.0-27.el7 os 156 k galera x86_64 25.3.28-1.rhel7.el7.centos mariadb 8.0 M 事務概要 ================================================================================================================================================================ 安裝 2 軟件包 (+4 依賴軟件包) 總下載量:46 M 安裝大小:196 M Downloading packages: 警告:/var/cache/yum/x86_64/7/mariadb/packages/MariaDB-common-10.2.31-1.el7.centos.x86_64.rpm: 頭V4 DSA/SHA1 Signature, 密鑰 ID 1bb943db: NOKEYkB 00:06:29 ETA MariaDB-common-10.2.31-1.el7.centos.x86_64.rpm 的公鑰尚未安裝 (1/6): MariaDB-common-10.2.31-1.el7.centos.x86_64.rpm | 81 kB 00:00:04 (2/6): MariaDB-compat-10.2.31-1.el7.centos.x86_64.rpm | 2.8 MB 00:00:02 (3/6): boost-program-options-1.53.0-27.el7.x86_64.rpm | 156 kB 00:00:00 (4/6): MariaDB-client-10.2.31-1.el7.centos.x86_64.rpm | 11 MB 00:00:11 (5/6): galera-25.3.28-1.rhel7.el7.centos.x86_64.rpm | 8.0 MB 00:00:02 (6/6): MariaDB-server-10.2.31-1.el7.centos.x86_64.rpm | 24 MB 00:00:10 ---------------------------------------------------------------------------------------------------------------------------------------------------------------- 總計 2.5 MB/s | 46 MB 00:00:17 從 https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB 檢索密鑰 導入 GPG key 0x1BB943DB: 用戶ID : "MariaDB Package Signing Key <package-signing-key@mariadb.org>" 指紋 : 1993 69e5 404b d5fc 7d2f e43b cbcb 082a 1bb9 43db 來自 : https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安裝 : MariaDB-compat-10.2.31-1.el7.centos.x86_64 1/6 正在安裝 : MariaDB-common-10.2.31-1.el7.centos.x86_64 2/6 正在安裝 : MariaDB-client-10.2.31-1.el7.centos.x86_64 3/6 正在安裝 : boost-program-options-1.53.0-27.el7.x86_64 4/6 正在安裝 : galera-25.3.28-1.rhel7.el7.centos.x86_64 5/6 正在安裝 : MariaDB-server-10.2.31-1.el7.centos.x86_64 6/6 PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER ! To do so, start the server, then issue the following commands: '/usr/bin/mysqladmin' -u root password 'new-password' '/usr/bin/mysqladmin' -u root -h guangzhou password 'new-password' Alternatively you can run: '/usr/bin/mysql_secure_installation' which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the MariaDB Knowledgebase at http://mariadb.com/kb or the MySQL manual for more instructions. Please report any problems at http://mariadb.org/jira The latest information about MariaDB is available at http://mariadb.org/. You can find additional information about the MySQL part at: http://dev.mysql.com Consider joining MariaDB's strong and vibrant community: https://mariadb.org/get-involved/ 驗證中 : galera-25.3.28-1.rhel7.el7.centos.x86_64 1/6 驗證中 : MariaDB-common-10.2.31-1.el7.centos.x86_64 2/6 驗證中 : MariaDB-server-10.2.31-1.el7.centos.x86_64 3/6 驗證中 : boost-program-options-1.53.0-27.el7.x86_64 4/6 驗證中 : MariaDB-client-10.2.31-1.el7.centos.x86_64 5/6 驗證中 : MariaDB-compat-10.2.31-1.el7.centos.x86_64 6/6 已安裝: MariaDB-client.x86_64 0:10.2.31-1.el7.centos MariaDB-server.x86_64 0:10.2.31-1.el7.centos 作為依賴被安裝: MariaDB-common.x86_64 0:10.2.31-1.el7.centos MariaDB-compat.x86_64 0:10.2.31-1.el7.centos boost-program-options.x86_64 0:1.53.0-27.el7 galera.x86_64 0:25.3.28-1.rhel7.el7.centos 完畢!
#啟動mariadb [root@guangzhou local]# systemctl start mariadb.service #初始化配置信息 [root@guangzhou local]# /usr/bin/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! #安裝完成 #運行 [root@guangzhou local]# mysql -h 127.0.0.1 -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 20 Server version: 10.2.31-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
#查看mariadb運行狀態
systemctl status mariadb
#啟動mariadb
systemctl start mariadb
#停止mariadb
#重新啟動
systemctl restart mariadb
#開機啟動
systemctl enable mariadb