Mariadb/MySQL安裝方式實戰篇html
做者:尹正傑 node
版權聲明:原創做品,謝絕轉載!不然將追究法律責任。python
一.如何選擇MySQL的安裝方式mysql
1>.選擇安裝的MySQL版本linux
1.首先判斷是否要和公司其餘已經安裝好的MySQL保持版本一致; 2.若是沒有上述要求,則通常會安裝最新版本(截止2019年1月初,目前最新MySQL版本是8.0.13); 3.若是不是實驗新功能特性,則不要選擇development release,而要安裝General Available(GA)release(表明穩定版本,可在生產環境中使用);
2>.下載正確的tar包ios
下載地址:https://dev.mysql.com/downloads/mysql/。
3>.如何選擇MySQL的安裝方式c++
1.程序包管理器管理yum/rpm方式安裝mysql yum/rpm方式安裝mysql安裝極其簡單,只要執行 yum -y install mysql-server便可。 yum/rpm安裝方式安裝MySQL應用場景: 適合對數據庫要求不過高的場合,例如併發不大,公司內部,企業內部的一些應用場景。大的門戶網站公司他們把源碼根據企業的需求製做出rpm,搭建yum倉庫,yum -y install xxx 2.源碼安裝mysql 此種方法適合全部的MySQL5.0.xx-5.1.xx產品系列,是最常規的編譯方式。 source code,通常狀況下會選擇二進制安裝方式,若是有特殊需求,好比修改一部源碼或修改MySQL深層次的配置,則會選擇源碼方式。 3.採用cmake方式編譯安裝MySQL 因爲MySQL5.5-5.6.xx產品系列特殊性,因此編譯方式也和早期的產品安裝方式不一樣,採用cmake或gmake方式編譯安裝。 4.採用二進制格式的程序包(展開至特定路徑,並通過簡單配置後便可使用)方式免編譯安裝MySQL 二進制安裝包的方式(RPM包,ZIP,Tar等),這種方法和yum /rpm 包安裝方式相似,適合各種MySQL產品系列,不須要複雜的編譯設置及編譯時間的等待,直接解壓下載的軟件包,初始化便可完成MySQL的安裝啓動 如何選擇MySQL的安裝方式 yum/rpm方式安裝MySQL適合於對數據庫要求不過高的場合,例如開發不大,公司內部,企業內部的一些應用場景。 二進制免安裝比較簡單方便,適合5.0-5.1和5.5-5.6系列,是不少DBA的選擇,普通Linux運維人員多采用編譯的方式,5.0-5.1系列就是常規編譯方式,5.5-5.6系列就是cmake編譯方式。 推薦:MySQL5.5及以上的版本;安裝方式機器數量少的話,使用cmake編譯方式;數量多的話採用二進制免安裝。 博主推薦閱讀: 使用二進制安裝包的方式單機部署MySQL8.0.13(https://www.cnblogs.com/yinzhengjie/p/10201038.html) 使用yum源的方式單機部署MySQL8.0.13(https://www.cnblogs.com/yinzhengjie/p/10212038.html)
二.基於yum方式安裝MySQLweb
在CentOS 6.x版本中的確存在MySQL的安裝包,但CentOS 7.x以後版本,MySQL的yum源被踢出,取而代之的是MariaDB源。 所以,咱們想要在CentOS 7.x版本上安裝MySQL,就須要查看MySQl官網提供的yum資源(https://dev.mysql.com/downloads/repo/yum/) 博主推薦閱讀: 使用yum源的方式單機部署MySQL8.0.13(https://www.cnblogs.com/yinzhengjie/p/10212038.html)
1>.安裝MySQL的yun源sql
[root@node101.yinzhengjie.org.cn ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm #下載官方的MySQLyum源,你也能夠在阿里源中下載對應的源。 --2019-10-24 18:24:58-- https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11 Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 25820 (25K) [application/x-redhat-package-manager] Saving to: ‘mysql80-community-release-el7-1.noarch.rpm’ 100%[=============================================================================================>] 25,820 165KB/s in 0.2s 2019-10-24 18:24:50 (165 KB/s) - ‘mysql80-community-release-el7-1.noarch.rpm’ saved [25820/25820] [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll total 28 -rw-r--r-- 1 root root 25820 Apr 18 2018 mysql80-community-release-el7-1.noarch.rpm [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/ | grep mysql [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# rpm -ivh mysql80-community-release-el7-1.noarch.rpm #安裝剛剛從官方下載的yum源,會在"/etc/yum.repos.d/"下生成相應的mysql社區版的repo配置文件。 warning: mysql80-community-release-el7-1.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql80-community-release-el7-1 ################################# [100%] [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/ | grep mysql -rw-r--r-- 1 root root 1864 Feb 22 2018 mysql-community.repo -rw-r--r-- 1 root root 1885 Feb 22 2018 mysql-community-source.repo [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
2>.安裝MySQL社區版服務docker
[root@node101.yinzhengjie.org.cn ~]# grep keepcache /etc/yum.conf keepcache=0 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# sed -i s'#keepcache=0#keepcache=1#' /etc/yum.conf #咱們開啓rpm緩存,使得安裝服務時下載的安裝包不會被自動刪除 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# grep keepcache /etc/yum.conf keepcache=1 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/ #默認存放yum服務的配置文件路徑 total 44 -rw-r--r--. 1 root root 1664 Nov 23 2018 CentOS-Base.repo -rw-r--r--. 1 root root 1309 Nov 23 2018 CentOS-CR.repo -rw-r--r--. 1 root root 649 Nov 23 2018 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 314 Nov 23 2018 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 Nov 23 2018 CentOS-Media.repo -rw-r--r--. 1 root root 1331 Nov 23 2018 CentOS-Sources.repo -rw-r--r--. 1 root root 5701 Nov 23 2018 CentOS-Vault.repo -rw-r--r-- 1 root root 2640 Oct 17 21:12 docker-ce.repo -rw-r--r-- 1 root root 1864 Feb 22 2018 mysql-community.repo -rw-r--r-- 1 root root 1885 Feb 22 2018 mysql-community-source.repo [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /var/cache/yum/$basearch/$releasever/x86_64/7 #默認存放下載全部rpm安裝包的路徑。 total 8 drwxr-xr-x. 4 root root 278 Oct 20 07:49 base drwxr-xr-x 4 root root 251 Oct 20 07:49 docker-ce-stable drwxr-xr-x. 4 root root 183 Oct 20 07:49 extras -rw-r--r-- 1 root root 580 Oct 20 07:49 timedhosts -rw-r--r--. 1 root root 517 Oct 18 20:24 timedhosts.txt drwxr-xr-x. 4 root root 183 Oct 20 07:49 updates [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# yum -y install mysql-community-server #安裝MySQL社區版 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.nju.edu.cn * extras: mirrors.nju.edu.cn * updates: mirrors.cn99.com base | 3.6 kB 00:00:00 docker-ce-stable | 3.5 kB 00:00:00 extras | 2.9 kB 00:00:00 mysql-connectors-community | 2.5 kB 00:00:00 mysql-tools-community | 2.5 kB 00:00:00 mysql80-community | 2.5 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/5): extras/7/x86_64/primary_db | 153 kB 00:00:00 (2/5): mysql-tools-community/x86_64/primary_db | 66 kB 00:00:01 (3/5): mysql80-community/x86_64/primary_db | 87 kB 00:00:01 (4/5): mysql-connectors-community/x86_64/primary_db | 48 kB 00:00:06 (5/5): updates/7/x86_64/primary_db | 2.8 MB 00:00:20 Resolving Dependencies --> Running transaction check ---> Package mysql-community-server.x86_64 0:8.0.18-1.el7 will be installed --> Processing Dependency: mysql-community-common(x86-64) = 8.0.18-1.el7 for package: mysql-community-server-8.0.18-1.el7.x86_64 --> Processing Dependency: mysql-community-client(x86-64) >= 8.0.11 for package: mysql-community-server-8.0.18-1.el7.x86_64 --> Running transaction check ---> Package mysql-community-client.x86_64 0:8.0.18-1.el7 will be installed --> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.18-1.el7.x86_64 ---> Package mysql-community-common.x86_64 0:8.0.18-1.el7 will be installed --> Running transaction check ---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be obsoleted --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-7.el7.x86_64 --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-7.el7.x86_64 ---> Package mysql-community-libs.x86_64 0:8.0.18-1.el7 will be obsoleting --> Running transaction check ---> Package mysql-community-libs-compat.x86_64 0:8.0.18-1.el7 will be obsoleting --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================= Package Arch Version Repository Size ======================================================================================================================================= Installing: mysql-community-libs x86_64 8.0.18-1.el7 mysql80-community 3.7 M replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5 mysql-community-libs-compat x86_64 8.0.18-1.el7 mysql80-community 1.3 M replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5 mysql-community-server x86_64 8.0.18-1.el7 mysql80-community 429 M Installing for dependencies: mysql-community-client x86_64 8.0.18-1.el7 mysql80-community 38 M mysql-community-common x86_64 8.0.18-1.el7 mysql80-community 597 k Transaction Summary ======================================================================================================================================= Install 3 Packages (+2 Dependent packages) Total download size: 473 M Downloading packages: warning: /var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-common-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signatur e, key ID 5072e1f5: NOKEYPublic key for mysql-community-common-8.0.18-1.el7.x86_64.rpm is not installed (1/5): mysql-community-common-8.0.18-1.el7.x86_64.rpm | 597 kB 00:00:07 (2/5): mysql-community-libs-8.0.18-1.el7.x86_64.rpm | 3.7 MB 00:00:02 (3/5): mysql-community-libs-compat-8.0.18-1.el7.x86_64.rpm | 1.3 MB 00:00:00 (4/5): mysql-community-server-8.0.18-1.el7.x86_64.rpm | 429 MB 00:05:17 (5/5): mysql-community-client-8.0.18-1.el7.x86_64.rp 94% [========================================- ] 14 kB/s | 447 MB 00:33:12 ETA (5/5): mysql-community-client-8.0.18-1.el7.x86_64.rp 94% [========================================- ] 14 kB/s | 447 MB 00:31:38 ETA (5/5): mysql-community-client-8.0.18-1.el7.x86_64.rpm | 38 MB 00:59:40 --------------------------------------------------------------------------------------------------------------------------------------- Total 135 kB/s | 473 MB 00:59:40 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Importing GPG key 0x5072E1F5: Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>" Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5 Package : mysql80-community-release-el7-1.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. Installing : mysql-community-common-8.0.18-1.el7.x86_64 1/6 Installing : mysql-community-libs-8.0.18-1.el7.x86_64 2/6 Installing : mysql-community-client-8.0.18-1.el7.x86_64 3/6 Installing : mysql-community-server-8.0.18-1.el7.x86_64 4/6 Installing : mysql-community-libs-compat-8.0.18-1.el7.x86_64 5/6 Erasing : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 6/6 Verifying : mysql-community-client-8.0.18-1.el7.x86_64 1/6 Verifying : mysql-community-common-8.0.18-1.el7.x86_64 2/6 Verifying : mysql-community-server-8.0.18-1.el7.x86_64 3/6 Verifying : mysql-community-libs-8.0.18-1.el7.x86_64 4/6 Verifying : mysql-community-libs-compat-8.0.18-1.el7.x86_64 5/6 Verifying : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 6/6 Installed: mysql-community-libs.x86_64 0:8.0.18-1.el7 mysql-community-libs-compat.x86_64 0:8.0.18-1.el7 mysql-community-server.x86_64 0:8.0.18-1.el7 Dependency Installed: mysql-community-client.x86_64 0:8.0.18-1.el7 mysql-community-common.x86_64 0:8.0.18-1.el7 Replaced: mariadb-libs.x86_64 1:5.5.60-1.el7_5 Complete! [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# rpm -ql mysql-community-server #查看安裝包中帶有的文件列表 /etc/logrotate.d/mysql /etc/my.cnf /etc/my.cnf.d /usr/bin/ibd2sdi /usr/bin/innochecksum /usr/bin/lz4_decompress /usr/bin/my_print_defaults /usr/bin/myisam_ftdump /usr/bin/myisamchk /usr/bin/myisamlog /usr/bin/myisampack /usr/bin/mysql_secure_installation /usr/bin/mysql_ssl_rsa_setup /usr/bin/mysql_tzinfo_to_sql /usr/bin/mysql_upgrade /usr/bin/mysqld_pre_systemd /usr/bin/mysqldumpslow /usr/bin/perror /usr/bin/zlib_decompress /usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/mysqld@.service /usr/lib/tmpfiles.d/mysql.conf /usr/lib64/mysql/mecab /usr/lib64/mysql/mecab/dic /usr/lib64/mysql/mecab/dic/ipadic_euc-jp /usr/lib64/mysql/mecab/dic/ipadic_euc-jp/char.bin /usr/lib64/mysql/mecab/dic/ipadic_euc-jp/dicrc /usr/lib64/mysql/mecab/dic/ipadic_euc-jp/left-id.def /usr/lib64/mysql/mecab/dic/ipadic_euc-jp/matrix.bin /usr/lib64/mysql/mecab/dic/ipadic_euc-jp/pos-id.def /usr/lib64/mysql/mecab/dic/ipadic_euc-jp/rewrite.def /usr/lib64/mysql/mecab/dic/ipadic_euc-jp/right-id.def /usr/lib64/mysql/mecab/dic/ipadic_euc-jp/sys.dic /usr/lib64/mysql/mecab/dic/ipadic_euc-jp/unk.dic /usr/lib64/mysql/mecab/dic/ipadic_sjis /usr/lib64/mysql/mecab/dic/ipadic_sjis/char.bin /usr/lib64/mysql/mecab/dic/ipadic_sjis/dicrc /usr/lib64/mysql/mecab/dic/ipadic_sjis/left-id.def /usr/lib64/mysql/mecab/dic/ipadic_sjis/matrix.bin /usr/lib64/mysql/mecab/dic/ipadic_sjis/pos-id.def /usr/lib64/mysql/mecab/dic/ipadic_sjis/rewrite.def /usr/lib64/mysql/mecab/dic/ipadic_sjis/right-id.def /usr/lib64/mysql/mecab/dic/ipadic_sjis/sys.dic /usr/lib64/mysql/mecab/dic/ipadic_sjis/unk.dic /usr/lib64/mysql/mecab/dic/ipadic_utf-8 /usr/lib64/mysql/mecab/dic/ipadic_utf-8/char.bin /usr/lib64/mysql/mecab/dic/ipadic_utf-8/dicrc /usr/lib64/mysql/mecab/dic/ipadic_utf-8/left-id.def /usr/lib64/mysql/mecab/dic/ipadic_utf-8/matrix.bin /usr/lib64/mysql/mecab/dic/ipadic_utf-8/pos-id.def /usr/lib64/mysql/mecab/dic/ipadic_utf-8/rewrite.def /usr/lib64/mysql/mecab/dic/ipadic_utf-8/right-id.def /usr/lib64/mysql/mecab/dic/ipadic_utf-8/sys.dic /usr/lib64/mysql/mecab/dic/ipadic_utf-8/unk.dic /usr/lib64/mysql/mecab/etc /usr/lib64/mysql/mecab/etc/mecabrc /usr/lib64/mysql/plugin /usr/lib64/mysql/plugin/adt_null.so /usr/lib64/mysql/plugin/auth_socket.so /usr/lib64/mysql/plugin/authentication_ldap_sasl_client.so /usr/lib64/mysql/plugin/component_audit_api_message_emit.so /usr/lib64/mysql/plugin/component_log_filter_dragnet.so /usr/lib64/mysql/plugin/component_log_sink_json.so /usr/lib64/mysql/plugin/component_log_sink_syseventlog.so /usr/lib64/mysql/plugin/component_mysqlbackup.so /usr/lib64/mysql/plugin/component_validate_password.so /usr/lib64/mysql/plugin/connection_control.so /usr/lib64/mysql/plugin/ddl_rewriter.so /usr/lib64/mysql/plugin/debug /usr/lib64/mysql/plugin/debug/adt_null.so /usr/lib64/mysql/plugin/debug/auth_socket.so /usr/lib64/mysql/plugin/debug/authentication_ldap_sasl_client.so /usr/lib64/mysql/plugin/debug/component_audit_api_message_emit.so /usr/lib64/mysql/plugin/debug/component_log_filter_dragnet.so /usr/lib64/mysql/plugin/debug/component_log_sink_json.so /usr/lib64/mysql/plugin/debug/component_log_sink_syseventlog.so /usr/lib64/mysql/plugin/debug/component_mysqlbackup.so /usr/lib64/mysql/plugin/debug/component_validate_password.so /usr/lib64/mysql/plugin/debug/connection_control.so /usr/lib64/mysql/plugin/debug/ddl_rewriter.so /usr/lib64/mysql/plugin/debug/group_replication.so /usr/lib64/mysql/plugin/debug/ha_example.so /usr/lib64/mysql/plugin/debug/ha_mock.so /usr/lib64/mysql/plugin/debug/innodb_engine.so /usr/lib64/mysql/plugin/debug/keyring_file.so /usr/lib64/mysql/plugin/debug/keyring_udf.so /usr/lib64/mysql/plugin/debug/libmemcached.so /usr/lib64/mysql/plugin/debug/libpluginmecab.so /usr/lib64/mysql/plugin/debug/locking_service.so /usr/lib64/mysql/plugin/debug/mypluglib.so /usr/lib64/mysql/plugin/debug/mysql_clone.so /usr/lib64/mysql/plugin/debug/mysql_no_login.so /usr/lib64/mysql/plugin/debug/rewrite_example.so /usr/lib64/mysql/plugin/debug/rewriter.so /usr/lib64/mysql/plugin/debug/semisync_master.so /usr/lib64/mysql/plugin/debug/semisync_slave.so /usr/lib64/mysql/plugin/debug/validate_password.so /usr/lib64/mysql/plugin/debug/version_token.so /usr/lib64/mysql/plugin/group_replication.so /usr/lib64/mysql/plugin/ha_example.so /usr/lib64/mysql/plugin/ha_mock.so /usr/lib64/mysql/plugin/innodb_engine.so /usr/lib64/mysql/plugin/keyring_file.so /usr/lib64/mysql/plugin/keyring_udf.so /usr/lib64/mysql/plugin/libmemcached.so /usr/lib64/mysql/plugin/libpluginmecab.so /usr/lib64/mysql/plugin/locking_service.so /usr/lib64/mysql/plugin/mypluglib.so /usr/lib64/mysql/plugin/mysql_clone.so /usr/lib64/mysql/plugin/mysql_no_login.so /usr/lib64/mysql/plugin/rewrite_example.so /usr/lib64/mysql/plugin/rewriter.so /usr/lib64/mysql/plugin/semisync_master.so /usr/lib64/mysql/plugin/semisync_slave.so /usr/lib64/mysql/plugin/validate_password.so /usr/lib64/mysql/plugin/version_token.so /usr/lib64/mysql/private /usr/lib64/mysql/private/libprotobuf-lite.so.3.6.1 /usr/lib64/mysql/private/libprotobuf.so.3.6.1 /usr/sbin/mysqld /usr/sbin/mysqld-debug /usr/share/doc/mysql-community-server-8.0.18 /usr/share/doc/mysql-community-server-8.0.18/INFO_BIN /usr/share/doc/mysql-community-server-8.0.18/INFO_SRC /usr/share/doc/mysql-community-server-8.0.18/LICENSE /usr/share/doc/mysql-community-server-8.0.18/README /usr/share/man/man1/ibd2sdi.1.gz /usr/share/man/man1/innochecksum.1.gz /usr/share/man/man1/lz4_decompress.1.gz /usr/share/man/man1/my_print_defaults.1.gz /usr/share/man/man1/myisam_ftdump.1.gz /usr/share/man/man1/myisamchk.1.gz /usr/share/man/man1/myisamlog.1.gz /usr/share/man/man1/myisampack.1.gz /usr/share/man/man1/mysql.server.1.gz /usr/share/man/man1/mysql_secure_installation.1.gz /usr/share/man/man1/mysql_ssl_rsa_setup.1.gz /usr/share/man/man1/mysql_tzinfo_to_sql.1.gz /usr/share/man/man1/mysql_upgrade.1.gz /usr/share/man/man1/mysqldumpslow.1.gz /usr/share/man/man1/mysqlman.1.gz /usr/share/man/man1/perror.1.gz /usr/share/man/man1/zlib_decompress.1.gz /usr/share/man/man8/mysqld.8.gz /usr/share/mysql-8.0/dictionary.txt /usr/share/mysql-8.0/innodb_memcached_config.sql /usr/share/mysql-8.0/install_rewriter.sql /usr/share/mysql-8.0/mysql-log-rotate /usr/share/mysql-8.0/uninstall_rewriter.sql /var/lib/mysql /var/lib/mysql-files /var/lib/mysql-keyring /var/run/mysqld [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/my.cnf #MySQL的客戶端和服務端均使用該配置文件 -rw-r--r-- 1 root root 1243 Sep 20 17:33 /etc/my.cnf [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# rpm -qf /etc/my.cnf #查看MySQL的配置文件來自於哪一個安裝包。 mysql-community-server-8.0.18-1.el7.x86_64 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /var/cache/yum/$basearch/$releasever/x86_64/7 #安裝MySQL服務端成功後,觀察該目錄下緩存相應的rpm包,能夠下載下來保存到本地用於製做公司私有的yum倉庫便於網絡下載更便捷。 total 8 drwxr-xr-x. 4 root root 278 Oct 25 05:50 base drwxr-xr-x 4 root root 251 Oct 25 05:50 docker-ce-stable drwxr-xr-x. 4 root root 183 Oct 25 05:50 extras drwxr-xr-x 4 root root 137 Oct 25 05:50 mysql80-community drwxr-xr-x 4 root root 137 Oct 25 05:50 mysql-connectors-community drwxr-xr-x 4 root root 137 Oct 25 05:50 mysql-tools-community -rw-r--r-- 1 root root 622 Oct 25 05:52 timedhosts -rw-r--r--. 1 root root 517 Oct 18 20:24 timedhosts.txt drwxr-xr-x. 4 root root 183 Oct 25 05:50 updates [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /var/cache/yum/$basearch/$releasever/x86_64/7/mysql* -R /var/cache/yum///x86_64/7/mysql80-community: total 96 -rw-r--r-- 1 root root 0 Oct 25 05:50 cachecookie -rw-r--r-- 1 root root 89466 Oct 10 19:46 f0cd25635b07e788d2c16d21791afd99f3e9e3d8-primary.sqlite.bz2 drwxr-xr-x 2 root root 31 Oct 24 18:37 gen drwxr-xr-x 2 root root 279 Oct 24 18:37 packages -rw-r--r-- 1 root root 2524 Oct 10 19:46 repomd.xml /var/cache/yum///x86_64/7/mysql80-community/gen: total 588 -rw-r--r-- 1 root root 600064 Oct 10 19:46 primary_db.sqlite /var/cache/yum///x86_64/7/mysql80-community/packages: total 484620 -rw-r--r-- 1 root root 40104640 Oct 10 19:45 mysql-community-client-8.0.18-1.el7.x86_64.rpm -rw-r--r-- 1 root root 611436 Oct 10 19:45 mysql-community-common-8.0.18-1.el7.x86_64.rpm -rw-r--r-- 1 root root 3877664 Oct 10 19:45 mysql-community-libs-8.0.18-1.el7.x86_64.rpm -rw-r--r-- 1 root root 1363968 Oct 10 19:45 mysql-community-libs-compat-8.0.18-1.el7.x86_64.rpm -rw-r--r-- 1 root root 450282440 Oct 10 19:45 mysql-community-server-8.0.18-1.el7.x86_64.rpm /var/cache/yum///x86_64/7/mysql-connectors-community: total 52 -rw-r--r-- 1 root root 0 Oct 25 05:50 cachecookie -rw-r--r-- 1 root root 48722 Oct 12 15:46 eb4609f765d6a231876f145d941bc65ab2964300-primary.sqlite.bz2 drwxr-xr-x 2 root root 31 Oct 24 18:37 gen drwxr-xr-x 2 root root 6 Oct 24 18:36 packages -rw-r--r-- 1 root root 2516 Oct 12 15:46 repomd.xml /var/cache/yum///x86_64/7/mysql-connectors-community/gen: total 360 -rw-r--r-- 1 root root 367616 Oct 12 15:46 primary_db.sqlite /var/cache/yum///x86_64/7/mysql-connectors-community/packages: total 0 /var/cache/yum///x86_64/7/mysql-tools-community: total 72 -rw-r--r-- 1 root root 0 Oct 25 05:50 cachecookie -rw-r--r-- 1 root root 67711 Oct 12 03:05 fd38dce5051dc3cb2a83cb5aaa1bfd26d52ec3ec-primary.sqlite.bz2 drwxr-xr-x 2 root root 31 Oct 24 18:37 gen drwxr-xr-x 2 root root 6 Oct 24 18:37 packages -rw-r--r-- 1 root root 2521 Oct 12 03:05 repomd.xml /var/cache/yum///x86_64/7/mysql-tools-community/gen: total 432 -rw-r--r-- 1 root root 440320 Oct 12 03:05 primary_db.sqlite /var/cache/yum///x86_64/7/mysql-tools-community/packages: total 0 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# rpm -q --scripts mysql-community-server #咱們發現MySQL的服務端腳本安裝時會自動幫咱們建立mysql用戶 preinstall scriptlet (using /bin/sh): /usr/sbin/groupadd -g 27 -o -r mysql >/dev/null 2>&1 || : /usr/sbin/useradd -M -N -g mysql -o -r -d /var/lib/mysql -s /bin/false \ -c "MySQL Server" -u 27 mysql >/dev/null 2>&1 || : postinstall scriptlet (using /bin/sh): [ -e /var/log/mysqld.log ] || install -m0640 -omysql -gmysql /dev/null /var/log/mysqld.log >/dev/null 2>&1 || : if [ $1 -eq 1 ] ; then # Initial installation systemctl preset mysqld.service >/dev/null 2>&1 || : fi /usr/bin/systemctl enable mysqld >/dev/null 2>&1 || : preuninstall scriptlet (using /bin/sh): if [ $1 -eq 0 ] ; then # Package removal, not upgrade systemctl --no-reload disable mysqld.service > /dev/null 2>&1 || : systemctl stop mysqld.service > /dev/null 2>&1 || : fi postuninstall scriptlet (using /bin/sh): systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then # Package upgrade, not uninstall systemctl try-restart mysqld.service >/dev/null 2>&1 || : fi [root@node101.yinzhengjie.org.cn ~]#
3>.啓動MySQL數據庫
[root@node101.yinzhengjie.org.cn ~]# ll /var/lib/mysql #默認的MySQL數據存儲目錄爲空 total 0 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# systemctl start mysqld #第一次啓動MySQL數據庫,觀察默認的MySQL數據存儲目錄"/var/lib/mysql"是否有數據生成。 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /var/lib/mysql #再次查看MySQL數據存儲目錄,發現多了不少初始文件和目錄 total 168004 -rw-r----- 1 mysql mysql 56 Oct 24 20:34 auto.cnf -rw-r----- 1 mysql mysql 155 Oct 24 20:34 binlog.000001 -rw-r----- 1 mysql mysql 16 Oct 24 20:34 binlog.index -rw------- 1 mysql mysql 1676 Oct 24 20:34 ca-key.pem -rw-r--r-- 1 mysql mysql 1112 Oct 24 20:34 ca.pem -rw-r--r-- 1 mysql mysql 1112 Oct 24 20:34 client-cert.pem -rw------- 1 mysql mysql 1676 Oct 24 20:34 client-key.pem -rw-r----- 1 mysql mysql 5906 Oct 24 20:34 ib_buffer_pool -rw-r----- 1 mysql mysql 12582912 Oct 24 20:35 ibdata1 -rw-r----- 1 mysql mysql 50331648 Oct 24 20:35 ib_logfile0 -rw-r----- 1 mysql mysql 50331648 Oct 24 20:34 ib_logfile1 -rw-r----- 1 mysql mysql 12582912 Oct 24 20:35 ibtmp1 drwxr-x--- 2 mysql mysql 187 Oct 24 20:34 #innodb_temp drwxr-x--- 2 mysql mysql 143 Oct 24 20:34 mysql -rw-r----- 1 mysql mysql 25165824 Oct 24 20:35 mysql.ibd srwxrwxrwx 1 mysql mysql 0 Oct 24 20:34 mysql.sock -rw------- 1 mysql mysql 5 Oct 24 20:34 mysql.sock.lock drwxr-x--- 2 mysql mysql 8192 Oct 24 20:34 performance_schema -rw------- 1 mysql mysql 1680 Oct 24 20:34 private_key.pem -rw-r--r-- 1 mysql mysql 452 Oct 24 20:34 public_key.pem -rw-r--r-- 1 mysql mysql 1112 Oct 24 20:34 server-cert.pem -rw------- 1 mysql mysql 1680 Oct 24 20:34 server-key.pem drwxr-x--- 2 mysql mysql 28 Oct 24 20:34 sys -rw-r----- 1 mysql mysql 10485760 Oct 24 20:35 undo_001 -rw-r----- 1 mysql mysql 10485760 Oct 24 20:35 undo_002 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# systemctl status mysqld #查看MySQL服務的狀態。 ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2019-10-24 20:34:58 CST; 6min ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 4021 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 4100 (mysqld) Status: "Server is operational" CGroup: /system.slice/mysqld.service └─4100 /usr/sbin/mysqld Oct 24 20:34:49 node101.yinzhengjie.org.cn systemd[1]: Starting MySQL Server... Oct 24 20:34:58 node101.yinzhengjie.org.cn systemd[1]: Started MySQL Server. [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ps aux | grep mysqld | grep -v grep #查看MySQL服務的mysqld進程是否存在 mysql 4100 0.7 4.8 2041748 386572 ? Ssl Oct24 3:52 /usr/sbin/mysqld [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ss -ntl #咱們發現默認的MySQL端口3306和33060已經啓動成功了 State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 128 :::3306 :::* LISTEN 0 128 :::22 :::* LISTEN 0 70 :::33060 :::* [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# yum -y install psmisc #安裝pstree命令行工具 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.nju.edu.cn * extras: mirrors.nju.edu.cn * updates: mirrors.cn99.com Resolving Dependencies --> Running transaction check ---> Package psmisc.x86_64 0:22.20-15.el7 will be updated ---> Package psmisc.x86_64 0:22.20-16.el7 will be an update --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================ Package Arch Version Repository Size ================================================================================================================ Updating: psmisc x86_64 22.20-16.el7 base 141 k Transaction Summary ================================================================================================================ Upgrade 1 Package Total download size: 141 k Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. psmisc-22.20-16.el7.x86_64.rpm | 141 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : psmisc-22.20-16.el7.x86_64 1/2 Cleanup : psmisc-22.20-15.el7.x86_64 2/2 Verifying : psmisc-22.20-16.el7.x86_64 1/2 Verifying : psmisc-22.20-15.el7.x86_64 2/2 Updated: psmisc.x86_64 0:22.20-16.el7 Complete! [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ps aux | grep mysql | grep -v grep mysql 4100 0.6 4.8 2041748 386572 ? Ssl Oct24 3:54 /usr/sbin/mysqld [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# pstree -p #注意觀察MySQL服務的mysqld進程是由mysql用戶啓動的並運行了子線程。 systemd(1)─┬─NetworkManager(3065)─┬─dhclient(3126) │ ├─{NetworkManager}(3092) │ └─{NetworkManager}(3094) ├─agetty(3363) ├─atd(3083) ├─auditd(3029)───{auditd}(3030) ├─crond(3069) ├─dbus-daemon(3058) ├─irqbalance(3056) ├─lvmetad(1657) ├─mysqld(4100)─┬─{mysqld}(4106) │ ├─{mysqld}(4107) │ ├─{mysqld}(4108) │ ├─{mysqld}(4109) │ ├─{mysqld}(4110) │ ├─{mysqld}(4111) │ ├─{mysqld}(4112) │ ├─{mysqld}(4113) │ ├─{mysqld}(4114) │ ├─{mysqld}(4115) │ ├─{mysqld}(4116) │ ├─{mysqld}(4117) │ ├─{mysqld}(4118) │ ├─{mysqld}(4119) │ ├─{mysqld}(4120) │ ├─{mysqld}(4121) │ ├─{mysqld}(4122) │ ├─{mysqld}(4123) │ ├─{mysqld}(4124) │ ├─{mysqld}(4125) │ ├─{mysqld}(4126) │ ├─{mysqld}(4127) │ ├─{mysqld}(4128) │ ├─{mysqld}(4129) │ ├─{mysqld}(4130) │ ├─{mysqld}(4131) │ ├─{mysqld}(4133) │ ├─{mysqld}(4136) │ ├─{mysqld}(4137) │ ├─{mysqld}(4138) │ ├─{mysqld}(4139) │ ├─{mysqld}(4140) │ ├─{mysqld}(4141) │ ├─{mysqld}(4142) │ ├─{mysqld}(4143) │ ├─{mysqld}(4144) │ ├─{mysqld}(4145) │ └─{mysqld}(4156) ├─polkitd(3055)─┬─{polkitd}(3062) │ ├─{polkitd}(3063) │ ├─{polkitd}(3064) │ ├─{polkitd}(3066) │ ├─{polkitd}(3079) │ └─{polkitd}(3090) ├─rsyslogd(3342)─┬─{rsyslogd}(3356) │ └─{rsyslogd}(3361) ├─sshd(3345)─┬─sshd(3736)───bash(3757) │ ├─sshd(3799)───bash(3801)───pstree(4756) │ └─sshd(3874)───bash(3876) ├─systemd-journal(1637) ├─systemd-logind(3052) ├─systemd-udevd(1659) └─tuned(3340)─┬─{tuned}(3620) ├─{tuned}(3621) ├─{tuned}(3622) └─{tuned}(3635) [root@node101.yinzhengjie.org.cn ~]#
4>.查看mysql的啓動日誌獲取MySQL數據庫初始化密碼
[root@node101.yinzhengjie.org.cn ~]# grep 'temporary password' /var/log/mysqld.log 2019-10-24T12:34:53.031896Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 1ym9qd,pyULn #標紅字符串時MySQL服務的初始化密碼。 [root@node101.yinzhengjie.org.cn ~]#
5>.鏈接mysql服務器並修改密碼
[root@node101.yinzhengjie.org.cn ~]# which mysql #查看MySQL的默認命令行客戶端鏈接工具完整路徑 /usr/bin/mysql [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /usr/bin/mysql -rwxr-xr-x 1 root root 19356128 Sep 20 17:23 /usr/bin/mysql [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# rpm -qf /usr/bin/mysql #查看MySQL客戶端命令mysql來自哪一個rpm安裝包 mysql-community-client-8.0.18-1.el7.x86_64 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# mysql -uroot -p #使用上面查詢到的MySQL初始化密碼登陸數據庫,登陸成功後會強制我們修改MySQL的root用戶密碼 Enter password: #輸入第4步重查詢標紅的字符串後登陸成功 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.0.18 Copyright (c) 2000, 2019, 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> mysql> SHOW DATABASES; #發現咱們沒法執行SHOW命令,登陸數據庫後它強制我們修改密碼 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. mysql> mysql> ALTER USER user() IDENTIFIED BY 'yinzhengjie'; #密碼的複雜度要高,不然會提示我們密碼策略不符合要求,咱們能夠經過修改"validate_password.policy"的屬性之來變動策略,但在此以前必須修修改複雜度較高的密碼。 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements mysql> mysql> ALTER USER user() IDENTIFIED BY 'yzj@2019MySQL'; #咱們按要求修改符合安全策略的密碼 Query OK, 0 rows affected (0.01 sec) mysql> mysql> EXIT Bye [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# mysql -uroot -pyzj@2019MySQL #使用修改後的密碼登陸數據庫並修改默認的密碼安全級別 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.18 MySQL Community Server - GPL Copyright (c) 2000, 2019, 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> mysql> SHOW VARIABLES LIKE '%validate_password_policy%'; #查看MySQL默認設置的密碼安全級別爲"MEDIUM"(除了長度要求外,該級別要求密碼中必須包含數字,大寫/小寫字母和特殊字符) +--------------------------+--------+ | Variable_name | Value | +--------------------------+--------+ | validate_password.policy | MEDIUM | +--------------------------+--------+ row in set (0.00 sec) mysql> mysql> SET GLOBAL validate_password.policy=0; #修改MySQL默認的安全級別爲LOW,這樣我們就能夠設置相對簡單的密碼啦,便於我們測試。 Query OK, 0 rows affected (0.00 sec) mysql> mysql> SHOW VARIABLES LIKE '%validate_password_policy%'; #再次查看MySQL默認安全策略,發現其值發生了變化。 +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | validate_password.policy | LOW | +--------------------------+-------+ row in set (0.01 sec) mysql> mysql> ALTER USER user() IDENTIFIED BY 'yinzhengjie'; #與此同時,咱們能夠設置安全策略較低的密碼。 Query OK, 0 rows affected (0.01 sec) mysql> mysql> QUIT Bye [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# mysql -uroot -pyinzhengjie #使用修改後的簡單密碼進行登陸 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 8.0.18 MySQL Community Server - GPL Copyright (c) 2000, 2019, 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> mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql>
validate_password_policy各項值說明:(密碼安全策略,默認MEDIUM策略) 0 or LOW: Length; 1 or MEDIUM(默認): Length;numeric, lowercase/uppercase, and special characters; 2 or STRONG: Length; numeric, lowercase/uppercase, and special characters; dictionary file
[root@node101.yinzhengjie.org.cn ~]# grep socket /etc/my.cnf #默認的本地socket鏈接文件 socket=/var/lib/mysql/mysql.sock [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# mysql -uroot -p -S /var/lib/mysql/mysql.sock #使用"-S"指定默認的本地socket鏈接文件,默認路徑在"/var/lib/mysql/mysql.sock",若是沒有修改默認路徑我們能夠不指定。 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 13 Server version: 8.0.18 MySQL Community Server - GPL Copyright (c) 2000, 2019, 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> mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql>
6>.MySQL客戶端命令
mysql客戶端經常使用選項: -A, --no-auto-rehash 禁止補全 -u, --user= 用戶名,默認爲root -h, --host= 服務器主機,默認爲localhost -p, --passowrd= 用戶密碼,建議使用-p,默認爲空密碼 -P, --port= 服務器端口 -S, --socket= 指定鏈接socket文件路徑 -D, --database= 指定默認數據庫 -C, --compress 啓用壓縮 -e 「SQL「 執行SQL命令 -V, --version 顯示版本 -v --verbose 顯示詳細信息 --print-defaults 獲取程序默認使用的配置
[root@node101.yinzhengjie.org.cn ~]# mysql --help #查看mysql命令的幫助信息 mysql Ver 8.0.18 for Linux on x86_64 (MySQL Community Server - GPL) Copyright (c) 2000, 2019, 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. Usage: mysql [OPTIONS] [database] -?, --help Display this help and exit. -I, --help Synonym for -? --auto-rehash Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash. (Defaults to on; use --skip-auto-rehash to disable.) -A, --no-auto-rehash No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. --auto-vertical-output Automatically switch to vertical output mode if the result is wider than the terminal width. -B, --batch Don't use history file. Disable interactive behavior. (Enables --silent.) --bind-address=name IP address to bind to. --binary-as-hex Print binary data as hex --character-sets-dir=name Directory for character set files. --column-type-info Display column type information. -c, --comments Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments. -C, --compress Use compression in server/client protocol. -#, --debug[=#] This is a non-debug version. Catch this and exit. --debug-check This is a non-debug version. Catch this and exit. -T, --debug-info This is a non-debug version. Catch this and exit. -D, --database=name Database to use. --default-character-set=name Set the default character set. --delimiter=name Delimiter to be used. --enable-cleartext-plugin Enable/disable the clear text authentication plugin. -e, --execute=name Execute command and quit. (Disables --force and history file.) -E, --vertical Print the output of a query (rows) vertically. -f, --force Continue even if we get an SQL error. --histignore=name A colon-separated list of patterns to keep statements from getting logged into syslog and mysql history. -G, --named-commands Enable named commands. Named commands mean this program's internal commands; see mysql> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default. -i, --ignore-spaces Ignore space after function names. --init-command=name SQL Command to execute when connecting to MySQL server. Will automatically be re-executed when reconnecting. --local-infile Enable/disable LOAD DATA LOCAL INFILE. -b, --no-beep Turn off beep on error. -h, --host=name Connect to host. -H, --html Produce HTML output. -X, --xml Produce XML output. --line-numbers Write line numbers for errors. (Defaults to on; use --skip-line-numbers to disable.) -L, --skip-line-numbers Don't write line number for errors. -n, --unbuffered Flush buffer after each query. --column-names Write column names in results. (Defaults to on; use --skip-column-names to disable.) -N, --skip-column-names Don't write column names in results. --sigint-ignore Ignore SIGINT (CTRL-C). -o, --one-database Ignore statements except those that occur while the default database is the one named at the command line. --pager[=name] Pager to use to display results. If you don't supply an option, the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\h) also. This option does not work in batch mode. Disable with --disable-pager. This option is disabled by default. -p, --password[=name] Password to use when connecting to server. If password is not given it's asked from the tty. -P, --port=# Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default (3306). --prompt=name Set the mysql prompt to this value. --protocol=name The protocol to use for connection (tcp, socket, pipe, memory). -q, --quick Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file. -r, --raw Write fields without conversion. Used with --batch. --reconnect Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default. (Defaults to on; use --skip-reconnect to disable.) -s, --silent Be more silent. Print results with a tab as separator, each row on new line. -S, --socket=name The socket file to use for connection. --server-public-key-path=name File path to the server public RSA key in PEM format. --get-server-public-key Get server public key --ssl-mode=name SSL connection mode. --ssl-ca=name CA file in PEM format. --ssl-capath=name CA directory. --ssl-cert=name X509 cert in PEM format. --ssl-cipher=name SSL cipher to use. --ssl-key=name X509 key in PEM format. --ssl-crl=name Certificate revocation list. --ssl-crlpath=name Certificate revocation list path. --tls-version=name TLS version to use, permitted values are: TLSv1, TLSv1.1, TLSv1.2, TLSv1.3 --ssl-fips-mode=name SSL FIPS mode (applies only for OpenSSL); permitted values are: OFF, ON, STRICT --tls-ciphersuites=name TLS v1.3 cipher to use. -t, --table Output in table format. --tee=name Append everything into outfile. See interactive help (\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default. -u, --user=name User for login if not current user. -U, --safe-updates Only allow UPDATE and DELETE that uses keys. -U, --i-am-a-dummy Synonym for option --safe-updates, -U. -v, --verbose Write more. (-v -v -v gives the table output format). -V, --version Output version information and exit. -w, --wait Wait and retry if connection is down. --connect-timeout=# Number of seconds before connection timeout. --max-allowed-packet=# The maximum packet length to send to or receive from server. --net-buffer-length=# The buffer size for TCP/IP and socket communication. --select-limit=# Automatic limit for SELECT when using --safe-updates. --max-join-size=# Automatic limit for rows in a join when using --safe-updates. --show-warnings Show warnings after every statement. -j, --syslog Log filtered interactive commands to syslog. Filtering of commands depends on the patterns supplied via histignore option besides the default patterns. --plugin-dir=name Directory for client-side plugins. --default-auth=name Default authentication client-side plugin to use. --binary-mode By default, ASCII '\0' is disallowed and '\r\n' is translated to '\n'. This switch turns off both features, and also turns off parsing of all clientcommands except \C and DELIMITER, in non-interactive mode (for input piped to mysql or loaded using the 'source' command). This is necessary when processing output from mysqlbinlog that may contain blobs. --connect-expired-password Notify the server that this client is prepared to handle expired password sandbox mode. --network-namespace=name Network namespace to use for connection via tcp with a server. --compression-algorithms=name Use compression algorithm in server/client protocol. Valid values are any combination of 'zstd','zlib','uncompressed'. --zstd-compression-level=# Use this compression level in the client/server protocol, in case --compression-algorithms=zstd. Valid range is between 1 and 22, inclusive. Default is 3. Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf The following groups are read: mysql client The following options may be given as the first argument: --print-defaults Print the program argument list and exit. --no-defaults Don't read default options from any option file, except for login file. --defaults-file=# Only read default options from the given file #. --defaults-extra-file=# Read this file after the global files are read. --defaults-group-suffix=# Also read groups with concat(group, suffix) --login-path=# Read this path from the login file. Variables (--variable-name=value) and boolean options {FALSE|TRUE} Value (after reading options) --------------------------------- ---------------------------------------- auto-rehash TRUE auto-vertical-output FALSE bind-address (No default value) binary-as-hex FALSE character-sets-dir (No default value) column-type-info FALSE comments FALSE compress FALSE database (No default value) default-character-set auto delimiter ; enable-cleartext-plugin FALSE vertical FALSE force FALSE histignore (No default value) named-commands FALSE ignore-spaces FALSE init-command (No default value) local-infile FALSE no-beep FALSE host (No default value) html FALSE xml FALSE line-numbers TRUE unbuffered FALSE column-names TRUE sigint-ignore FALSE port 0 prompt mysql> quick FALSE raw FALSE reconnect TRUE socket (No default value) server-public-key-path (No default value) get-server-public-key FALSE ssl-ca (No default value) ssl-capath (No default value) ssl-cert (No default value) ssl-cipher (No default value) ssl-key (No default value) ssl-crl (No default value) ssl-crlpath (No default value) tls-version (No default value) tls-ciphersuites (No default value) table FALSE user (No default value) safe-updates FALSE i-am-a-dummy FALSE connect-timeout 0 max-allowed-packet 16777216 net-buffer-length 16384 select-limit 1000 max-join-size 1000000 show-warnings FALSE plugin-dir (No default value) default-auth (No default value) binary-mode FALSE connect-expired-password FALSE network-namespace (No default value) compression-algorithms (No default value) zstd-compression-level 3 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# man mysql #共計有1492行幫助信息,相對上面的幫助信息更全面
[root@node101.yinzhengjie.org.cn ~]# mysql -uroot -p -S /var/lib/mysql/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 14 Server version: 8.0.18 MySQL Community Server - GPL Copyright (c) 2000, 2019, 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> mysql> help; #查看MySQL客戶端(mysql命令行工具)專有命令,所以咱們使用其它MySQL客戶端工具鏈接MySQL服務端(mysqld)可能沒有這些命令,與之對應的還有MySQL服務端命令。 For information about MySQL products and services, visit: http://www.mysql.com/ For developer information, including the MySQL Reference Manual, visit: http://dev.mysql.com/ To buy MySQL Enterprise support, training, or other products, visit: https://shop.mysql.com/ List of all MySQL commands: Note that all text commands must be first on line and end with ';' ? (\?) Synonym for `help'. clear (\c) Clear the current input statement. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to mysql server, display result vertically. exit (\q) Exit mysql. Same as quit. go (\g) Send command to mysql server. help (\h) Display this help. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. print (\p) Print current command. prompt (\R) Change your mysql prompt. quit (\q) Quit mysql. rehash (\#) Rebuild completion hash. source (\.) Execute an SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement. resetconnection(\x) Clean session context. For server side help, type 'help contents' mysql>
mysql> STATUS #從服務器獲取狀態信息。 -------------- mysql Ver 8.0.18 for Linux on x86_64 (MySQL Community Server - GPL) Connection id: 14 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 8.0.18 MySQL Community Server - GPL Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8mb4 Db characterset: utf8mb4 Client characterset: utf8mb4 Conn. characterset: utf8mb4 UNIX socket: /var/lib/mysql/mysql.sock Uptime: 10 hours 26 min 53 sec Threads: 2 Questions: 28 Slow queries: 0 Opens: 177 Flush tables: 3 Open tables: 94 Queries per second avg: 0.000 -------------- mysql>
mysql> SYSTEM hostname #在mysql命令行調用Linux命令 node101.yinzhengjie.org.cn mysql>
mysql> prompt node101.yinzhengjie.org.cn[mysql]--> #臨時修改當前命令行的提示符信息 PROMPT set to 'node101.yinzhengjie.org.cn[mysql]-->' node101.yinzhengjie.org.cn[mysql]--> node101.yinzhengjie.org.cn[mysql]-->system free -h total used free shared buff/cache available Mem: 7.6G 509M 4.0G 8.6M 3.1G 6.8G Swap: 7.9G 0B 7.9G node101.yinzhengjie.org.cn[mysql]--> node101.yinzhengjie.org.cn[mysql]-->
[root@node101.yinzhengjie.org.cn ~]# mysql -uroot -p --prompt="\u@[\D]-->" #啓動mysql客戶端鏈接時臨時指定提示符信息 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 16 Server version: 8.0.18 MySQL Community Server - GPL Copyright (c) 2000, 2019, 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. root@[Fri Oct 25 07:36:43 2019]--> root@[Fri Oct 25 07:36:44 2019]-->SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) root@[Fri Oct 25 07:36:48 2019]-->QUIT Bye [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# tail -2 /etc/my.cnf #將MySQL客戶端的配置寫入配置文件,這些配置就會永久生效。 [mysql] prompt="\u@[\D]->" [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 18 Server version: 8.0.18 MySQL Community Server - GPL Copyright (c) 2000, 2019, 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. root@[Fri Oct 25 07:45:36 2019]-> root@[Fri Oct 25 07:45:37 2019]->SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) root@[Fri Oct 25 07:45:41 2019]-> root@[Fri Oct 25 07:45:42 2019]->QUIT Bye [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
7>.運行MySQL/MariaDB自帶的安全腳本(提升安全性)
[root@node102.yinzhengjie.org.cn ~]# mysql #默認狀況下MariaDB無需輸入密碼便可登陸數據庫,查看數據庫及用戶信息 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 16 Server version: 5.5.64-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 [(none)]> SHOW DATABASES; #查看現有的數據庫,存在test數據庫。 +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ rows in set (0.00 sec) MariaDB [(none)]> MariaDB [mysql]> SELECT host,user,password FROM user; #查看默認的mysql服務用戶信息,發現有不少匿名用戶且密碼爲空。 +----------------------------+------+----------+ | host | user | password | +----------------------------+------+----------+ | localhost | root | | | node102.yinzhengjie.org.cn | root | | | 127.0.0.1 | root | | | ::1 | root | | | localhost | | | | node102.yinzhengjie.org.cn | | | +----------------------------+------+----------+ rows in set (0.00 sec) MariaDB [mysql]>
[root@node102.yinzhengjie.org.cn ~]# mysql_secure_installation #啓動MySQL/MaraDB默認的安全策略腳本,根據提示輸入對應的選項便可。 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): #輸入MySQL/MariaDB的默認密碼,若是沒有設置密碼直接回車便可。 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 #輸入"y",表示設置root密碼 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 #輸入"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 #輸入"y",禁用root遠程登陸 ... 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 #輸入"y",移除"test"數據庫 - 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 #輸入"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@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# mysql -p #須要使用使用腳本設置的密碼登陸,再次查看數據庫及用戶信息。 Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 29 Server version: 5.5.64-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 [(none)]> SHOW DATABASES; #發現"test"數據庫不存在啦 +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.00 sec) MariaDB [(none)]> MariaDB [(none)]> SELECT host,user,password FROM mysql.user; #發現匿名用戶被刪除了,目前僅容許本機登陸。 +-----------+------+-------------------------------------------+ | host | user | password | +-----------+------+-------------------------------------------+ | localhost | root | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | | 127.0.0.1 | root | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | | ::1 | root | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | +-----------+------+-------------------------------------------+ 3 rows in set (0.00 sec) MariaDB [(none)]>
8>.用戶帳號
mysql用戶帳號由兩部分組成: 'USERNAME'@'HOST‘ 說明: HOST限制此用戶可經過哪些遠程主機鏈接mysql服務器 支持使用通配符: % 匹配任意長度的任意字符 172.30.1.0/255.255.255.0 或 172.30.1.% _ 匹配任意單個字符
9>.Mysql 客戶端使用模式
交互式模式: 可運行命令有兩類: 客戶端命令: \h, help \u,use \s,status \!,system 服務器端命令: SQL語句, 須要語句結束符;
腳本模式: mysql –uUSERNAME -pPASSWORD < /path/somefile.sql mysql> source /path/from/somefile.sql
[root@node102.yinzhengjie.org.cn ~]# cat test.sql SELECT NOW(); SHOW DATABASES; SELECT host,user,password FROM mysql.user; [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# mysql -uroot -pyinzhengjie < test.sql #批量執行一個SQL腳本,這樣就省的咱們人工一條一條敲了。 NOW() 2019-10-25 10:09:18 Database information_schema mysql performance_schema host user password localhost root *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 127.0.0.1 root *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 ::1 root *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# cat test.sql | mysql -uroot -pyinzhengjie #上面的方法也等效於這種寫法的結果 NOW() 2019-10-25 10:10:06 Database information_schema mysql performance_schema host user password localhost root *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 127.0.0.1 root *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 ::1 root *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# mysql -uroot -pyinzhengjie -e 'SELECT host,user,password FROM mysql.user' #命令行使用非交互式方式執行SQL語句 +-----------+------+-------------------------------------------+ | host | user | password | +-----------+------+-------------------------------------------+ | localhost | root | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | | 127.0.0.1 | root | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | | ::1 | root | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | +-----------+------+-------------------------------------------+ [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# mysql -uroot -pyinzhengjie -e 'SHOW DATABASES;' +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# cat test.sql SELECT NOW(); SHOW DATABASES; SELECT host,user,password FROM mysql.user; [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# mysql -uroot -pyinzhengjie Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 5.5.64-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 [(none)]> SOURCE test.sql #交互式命令行中執行SQL腳本 +---------------------+ | NOW() | +---------------------+ | 2019-10-25 10:14:53 | +---------------------+ 1 row in set (0.00 sec) +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.00 sec) +-----------+------+-------------------------------------------+ | host | user | password | +-----------+------+-------------------------------------------+ | localhost | root | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | | 127.0.0.1 | root | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | | ::1 | root | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | +-----------+------+-------------------------------------------+ 3 rows in set (0.00 sec) MariaDB [(none)]>
10>.服務器監聽的兩種socket地址
ip socket:
監聽在tcp的3306端口,支持遠程通訊
unix sock:
監聽在sock文件上,僅支持本機通訊。如:/var/lib/mysql/mysql.sock)
說明:host爲localhost,127.0.0.1時自動使用unix sock
[root@node102.yinzhengjie.org.cn ~]# ll /var/lib/mysql/mysql.sock #默認的本地socket鏈接文件 srwxrwxrwx 1 mysql mysql 0 Oct 25 06:26 /var/lib/mysql/mysql.sock [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# mysql -S /var/lib/mysql/mysql.sock #使用"-S"指定默認的本地socket鏈接文件,默認路徑在"/var/lib/mysql/mysql.sock",若是沒有修改默認路徑我們能夠不指定。 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 6 Server version: 5.5.64-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)]> help General information about MariaDB can be found at http://mariadb.org List of all MySQL commands: Note that all text commands must be first on line and end with ';' ? (\?) Synonym for `help'. clear (\c) Clear the current input statement. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to mysql server, display result vertically. exit (\q) Exit mysql. Same as quit. go (\g) Send command to mysql server. help (\h) Display this help. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. print (\p) Print current command. prompt (\R) Change your mysql prompt. quit (\q) Quit mysql. rehash (\#) Rebuild completion hash. source (\.) Execute an SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement. For server side help, type 'help contents' MariaDB [(none)]> EXIT Bye [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# ll /var/lib/mysql/ total 28700 -rw-rw---- 1 mysql mysql 16384 Oct 25 09:57 aria_log.00000001 -rw-rw---- 1 mysql mysql 52 Oct 25 09:57 aria_log_control -rw-rw---- 1 mysql mysql 18874368 Oct 25 09:57 ibdata1 -rw-rw---- 1 mysql mysql 5242880 Oct 25 10:07 ib_logfile0 -rw-rw---- 1 mysql mysql 5242880 Oct 25 06:26 ib_logfile1 drwx------ 2 mysql mysql 4096 Oct 25 06:26 mysql srwxrwxrwx 1 mysql mysql 0 Oct 25 10:07 mysql.sock drwx------ 2 mysql mysql 4096 Oct 25 06:26 performance_schema [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# mysqladmin -uroot -pyinzhengjie shutdown #關閉MySQL/MariaDB服務,觀察"mysql.sock"是否自動消失。 [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# ll /var/lib/mysql/ total 28700 -rw-rw---- 1 mysql mysql 16384 Oct 25 10:24 aria_log.00000001 -rw-rw---- 1 mysql mysql 52 Oct 25 10:24 aria_log_control -rw-rw---- 1 mysql mysql 18874368 Oct 25 10:24 ibdata1 -rw-rw---- 1 mysql mysql 5242880 Oct 25 10:24 ib_logfile0 -rw-rw---- 1 mysql mysql 5242880 Oct 25 06:26 ib_logfile1 drwx------ 2 mysql mysql 4096 Oct 25 06:26 mysql drwx------ 2 mysql mysql 4096 Oct 25 06:26 performance_schema [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# systemctl start mariadb [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# ll /var/lib/mysql/ total 28700 -rw-rw---- 1 mysql mysql 16384 Oct 25 10:24 aria_log.00000001 -rw-rw---- 1 mysql mysql 52 Oct 25 10:24 aria_log_control -rw-rw---- 1 mysql mysql 18874368 Oct 25 10:24 ibdata1 -rw-rw---- 1 mysql mysql 5242880 Oct 25 10:24 ib_logfile0 -rw-rw---- 1 mysql mysql 5242880 Oct 25 06:26 ib_logfile1 drwx------ 2 mysql mysql 4096 Oct 25 06:26 mysql srwxrwxrwx 1 mysql mysql 0 Oct 25 10:24 mysql.sock drwx------ 2 mysql mysql 4096 Oct 25 06:26 performance_schema [root@node102.yinzhengjie.org.cn ~]#
11>.執行命令
運行mysql命令:默認空密碼登陸 mysql>use mysql mysql>select user();查看當前用戶 mysql>SELECT User,Host,Password FROM user;
登陸系統:
mysql –uroot –p
客戶端命令:本地執行 mysql> help 每一個命令都完整形式和簡寫格式 mysql> status 或 \s
服務端命令:經過mysql協議發往服務器執行並取回結果 每一個命令末尾都必須使用命令結束符號,默認爲分號 示例:SELECT VERSION();
12>.服務器端配置
服務器端(mysqld):工做特性有多種配置方式 1>.命令行選項: 2>.配置文件:類ini格式 集中式的配置,可以爲mysql的各應用程序提供配置信息: [mysqld]
針對MySQL主程序mysqld定義參數。 [mysqld_safe]
針對MySQL安全性的參數 [mysqld_multi]
針對MySQL多實例參數。 [mysql]
針對MySQL客戶端參數。 [mysqldump]
針對MySQL備份相關參數。 [server]
統一爲服務器使用。 [client]
統一爲客戶端使用。 格式: parameter = value 說明: _和- 相同 1,ON,TRUE意義相同, 0,OFF,FALSE意義相同
13>.配置文件
後面覆蓋前面的配置文件,順序以下: /etc/my.cnf Global選項 /etc/mysql/my.cnf Global選項 SYSCONFDIR/my.cnf Global選項(編譯選項) $MYSQL_HOME/my.cnf Server-specific 選項 --defaults-extra-file=path (啓動MySQL時使用該選項指定配置文件) ~/.my.cnf User-specific 選項
注意:以上順序自上而下可同時指定多個配置文件,但誰在最下面誰的配置文件優先級最高,即後面的會覆蓋前面的配置,相似於編程語言變量的定義。
三.基於yum方式安裝Mariadb
基於默認的yum源時能夠安裝的MariaDB,但版本較低,能夠基於yum方式安裝MySQL同樣去MariaDB官網找到對應版本的yum源下載安裝便可。
官網地址:https://downloads.mariadb.org/mariadb/repositories/#mirror=iweb
1>.CentOS 7.6安裝Mariadb
[root@node102.yinzhengjie.org.cn ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# uname -r 3.10.0-957.el7.x86_64 [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# uname -m x86_64 [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# yum info mariadb #查看Mariadb數據庫的相關信息 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.huaweicloud.com * extras: mirrors.cn99.com * updates: mirrors.cn99.com Available Packages Name : mariadb Arch : x86_64 Epoch : 1 Version : 5.5.64 Release : 1.el7 Size : 8.7 M Repo : base/7/x86_64 Summary : A community developed branch of MySQL URL : http://mariadb.org License : GPLv2 with exceptions and LGPLv2 and BSD Description : MariaDB is a community developed branch of MySQL. : MariaDB is a multi-user, multi-threaded SQL database server. : It is a client/server implementation consisting of a server daemon (mysqld) : and many different client programs and libraries. The base package : contains the standard MariaDB/MySQL client programs and generic MySQL files. [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# yum -y install mariadb-server #安裝mariadb服務端時,它會自動安裝客戶端 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.huaweicloud.com * extras: mirrors.cn99.com * updates: mirrors.cn99.com Resolving Dependencies --> Running transaction check ---> Package mariadb-server.x86_64 1:5.5.64-1.el7 will be installed --> Processing Dependency: mariadb(x86-64) = 1:5.5.64-1.el7 for package: 1:mariadb-server-5.5.64-1.el7.x86_64 --> Processing Dependency: perl-DBI for package: 1:mariadb-server-5.5.64-1.el7.x86_64 --> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.64-1.el7.x86_64 --> Processing Dependency: perl(DBI) for package: 1:mariadb-server-5.5.64-1.el7.x86_64 --> Running transaction check ---> Package mariadb.x86_64 1:5.5.64-1.el7 will be installed ---> Package perl-DBD-MySQL.x86_64 0:4.023-6.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 --> 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 --> Running transaction check ---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================= Package Arch Version Repository Size ================================================================================================================================================= Installing: mariadb-server x86_64 1:5.5.64-1.el7 base 11 M Installing for dependencies: mariadb x86_64 1:5.5.64-1.el7 base 8.7 M perl-DBD-MySQL x86_64 4.023-6.el7 base 140 k perl-DBI x86_64 1.627-4.el7 base 802 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 (+5 Dependent packages) Total size: 21 M Total download size: 20 M Installed size: 109 M Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. (1/2): mariadb-5.5.64-1.el7.x86_64.rpm | 8.7 MB 00:00:01 (2/2): mariadb-server-5.5.64-1.el7.x86_64.rpm | 11 MB 00:00:06 ------------------------------------------------------------------------------------------------------------------------------------------------- Total 2.9 MB/s | 20 MB 00:00:06 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:mariadb-5.5.64-1.el7.x86_64 1/6 Installing : perl-Net-Daemon-0.48-5.el7.noarch 2/6 Installing : perl-PlRPC-0.2020-14.el7.noarch 3/6 Installing : perl-DBI-1.627-4.el7.x86_64 4/6 Installing : perl-DBD-MySQL-4.023-6.el7.x86_64 5/6 Installing : 1:mariadb-server-5.5.64-1.el7.x86_64 6/6 Verifying : perl-Net-Daemon-0.48-5.el7.noarch 1/6 Verifying : 1:mariadb-5.5.64-1.el7.x86_64 2/6 Verifying : perl-DBD-MySQL-4.023-6.el7.x86_64 3/6 Verifying : 1:mariadb-server-5.5.64-1.el7.x86_64 4/6 Verifying : perl-DBI-1.627-4.el7.x86_64 5/6 Verifying : perl-PlRPC-0.2020-14.el7.noarch 6/6 Installed: mariadb-server.x86_64 1:5.5.64-1.el7 Dependency Installed: mariadb.x86_64 1:5.5.64-1.el7 perl-DBD-MySQL.x86_64 0:4.023-6.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 Complete! [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# rpm -ql mariadb-server #查看安裝包中帶有的文件列表 /etc/logrotate.d/mariadb /etc/my.cnf.d/server.cnf /usr/bin/innochecksum /usr/bin/myisam_ftdump /usr/bin/myisamchk /usr/bin/myisamlog /usr/bin/myisampack /usr/bin/mysql_convert_table_format /usr/bin/mysql_fix_extensions /usr/bin/mysql_install_db /usr/bin/mysql_plugin /usr/bin/mysql_secure_installation /usr/bin/mysql_setpermission /usr/bin/mysql_tzinfo_to_sql /usr/bin/mysql_upgrade /usr/bin/mysql_zap /usr/bin/mysqlbug /usr/bin/mysqld_multi /usr/bin/mysqld_safe /usr/bin/mysqld_safe_helper /usr/bin/mysqldumpslow /usr/bin/mysqlhotcopy /usr/bin/mysqltest /usr/bin/perror /usr/bin/replace /usr/bin/resolve_stack_dump /usr/bin/resolveip /usr/lib/systemd/system/mariadb.service /usr/lib/tmpfiles.d/mariadb.conf /usr/lib64/mysql/INFO_BIN /usr/lib64/mysql/INFO_SRC /usr/lib64/mysql/mysqlbug /usr/lib64/mysql/plugin /usr/lib64/mysql/plugin/adt_null.so /usr/lib64/mysql/plugin/auth_0x0100.so /usr/lib64/mysql/plugin/auth_pam.so /usr/lib64/mysql/plugin/auth_socket.so /usr/lib64/mysql/plugin/auth_test_plugin.so /usr/lib64/mysql/plugin/daemon_example.ini /usr/lib64/mysql/plugin/dialog_examples.so /usr/lib64/mysql/plugin/ha_innodb.so /usr/lib64/mysql/plugin/ha_sphinx.so /usr/lib64/mysql/plugin/handlersocket.so /usr/lib64/mysql/plugin/libdaemon_example.so /usr/lib64/mysql/plugin/mypluglib.so /usr/lib64/mysql/plugin/qa_auth_client.so /usr/lib64/mysql/plugin/qa_auth_interface.so /usr/lib64/mysql/plugin/qa_auth_server.so /usr/lib64/mysql/plugin/query_cache_info.so /usr/lib64/mysql/plugin/semisync_master.so /usr/lib64/mysql/plugin/semisync_slave.so /usr/lib64/mysql/plugin/server_audit.so /usr/lib64/mysql/plugin/sphinx.so /usr/lib64/mysql/plugin/sql_errlog.so /usr/libexec/mariadb-prepare-db-dir /usr/libexec/mariadb-wait-ready /usr/libexec/mysqld /usr/share/man/man1/innochecksum.1.gz /usr/share/man/man1/msql2mysql.1.gz /usr/share/man/man1/myisam_ftdump.1.gz /usr/share/man/man1/myisamchk.1.gz /usr/share/man/man1/myisamlog.1.gz /usr/share/man/man1/myisampack.1.gz /usr/share/man/man1/mysql.server.1.gz /usr/share/man/man1/mysql_convert_table_format.1.gz /usr/share/man/man1/mysql_fix_extensions.1.gz /usr/share/man/man1/mysql_install_db.1.gz /usr/share/man/man1/mysql_plugin.1.gz /usr/share/man/man1/mysql_secure_installation.1.gz /usr/share/man/man1/mysql_setpermission.1.gz /usr/share/man/man1/mysql_tzinfo_to_sql.1.gz /usr/share/man/man1/mysql_upgrade.1.gz /usr/share/man/man1/mysql_zap.1.gz /usr/share/man/man1/mysqlbinlog.1.gz /usr/share/man/man1/mysqlbug.1.gz /usr/share/man/man1/mysqlcheck.1.gz /usr/share/man/man1/mysqld_multi.1.gz /usr/share/man/man1/mysqld_safe.1.gz /usr/share/man/man1/mysqldumpslow.1.gz /usr/share/man/man1/mysqlhotcopy.1.gz /usr/share/man/man1/mysqlimport.1.gz /usr/share/man/man1/mysqltest.1.gz /usr/share/man/man1/perror.1.gz /usr/share/man/man1/replace.1.gz /usr/share/man/man1/resolve_stack_dump.1.gz /usr/share/man/man1/resolveip.1.gz /usr/share/man/man8/mysqld.8.gz /usr/share/mysql/README.mysql-cnf /usr/share/mysql/errmsg-utf8.txt /usr/share/mysql/fill_help_tables.sql /usr/share/mysql/my-huge.cnf /usr/share/mysql/my-innodb-heavy-4G.cnf /usr/share/mysql/my-large.cnf /usr/share/mysql/my-medium.cnf /usr/share/mysql/my-small.cnf /usr/share/mysql/mysql_performance_tables.sql /usr/share/mysql/mysql_system_tables.sql /usr/share/mysql/mysql_system_tables_data.sql /usr/share/mysql/mysql_test_data_timezone.sql /var/lib/mysql /var/log/mariadb /var/log/mariadb/mariadb.log /var/run/mariadb [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# rpm -q --scripts mariadb-server #安裝Mariadb服務端會自動建立mysql用戶 preinstall scriptlet (using /bin/sh): /usr/sbin/groupadd -g 27 -o -r mysql >/dev/null 2>&1 || : /usr/sbin/useradd -M -N -g mysql -o -r -d /var/lib/mysql -s /sbin/nologin \ -c "MariaDB Server" -u 27 mysql >/dev/null 2>&1 || : postinstall scriptlet (using /bin/sh): if [ $1 -eq 1 ] ; then # Initial installation systemctl preset mariadb.service >/dev/null 2>&1 || : fi /bin/chmod 0755 /var/lib/mysql /bin/touch /var/log/mariadb/mariadb.log /usr/sbin/update-alternatives --install /usr/bin/mysqlbug \ mysqlbug /usr/lib64/mysql/mysqlbug 64 preuninstall scriptlet (using /bin/sh): if [ $1 -eq 0 ] ; then # Package removal, not upgrade systemctl --no-reload disable mariadb.service > /dev/null 2>&1 || : systemctl stop mariadb.service > /dev/null 2>&1 || : fi postuninstall scriptlet (using /bin/sh): systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then # Package upgrade, not uninstall systemctl try-restart mariadb.service >/dev/null 2>&1 || : fi if [ $1 -eq 0 ] ; then /usr/sbin/update-alternatives --remove mysqlbug /usr/lib64/mysql/mysqlbug fi [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# id mysql uid=27(mysql) gid=27(mysql) groups=27(mysql) [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# grep mysql /etc/passwd mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]#
2>.啓動Mariadb服務端
[root@node102.yinzhengjie.org.cn ~]# ll /var/lib/mysql/ #默認的數據存儲目錄爲空 total 0 [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# systemctl start mariadb #第一次啓動Mariadb數據庫,觀察數據存儲目錄("/var/lib/mysql/")是否有數據生成。 [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# ll /var/lib/mysql/ #再次查看數據存儲目錄,發現的確有相應的數據生成。 total 37852 -rw-rw---- 1 mysql mysql 16384 Oct 25 06:26 aria_log.00000001 -rw-rw---- 1 mysql mysql 52 Oct 25 06:26 aria_log_control -rw-rw---- 1 mysql mysql 18874368 Oct 25 06:26 ibdata1 -rw-rw---- 1 mysql mysql 5242880 Oct 25 06:26 ib_logfile0 -rw-rw---- 1 mysql mysql 5242880 Oct 25 06:26 ib_logfile1 drwx------ 2 mysql mysql 4096 Oct 25 06:26 mysql srwxrwxrwx 1 mysql mysql 0 Oct 25 06:26 mysql.sock drwx------ 2 mysql mysql 4096 Oct 25 06:26 performance_schema drwx------ 2 mysql mysql 6 Oct 25 06:26 test [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# systemctl status mariadb #查看Mariadb服務的狀態 ● mariadb.service - MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Active: active (running) since Fri 2019-10-25 06:26:44 CST; 9min ago Process: 7830 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS) Process: 7743 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS) Main PID: 7829 (mysqld_safe) CGroup: /system.slice/mariadb.service ├─7829 /bin/sh /usr/bin/mysqld_safe --basedir=/usr └─7991 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariad... Oct 25 06:26:42 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[7743]: MySQL manual for more instructions. Oct 25 06:26:42 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[7743]: Please report any problems at http://mariadb.org/jira Oct 25 06:26:42 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[7743]: The latest information about MariaDB is available at http://mari...org/. Oct 25 06:26:42 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[7743]: You can find additional information about the MySQL part at: Oct 25 06:26:42 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[7743]: http://dev.mysql.com Oct 25 06:26:42 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[7743]: Consider joining MariaDB's strong and vibrant community: Oct 25 06:26:42 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[7743]: https://mariadb.org/get-involved/ Oct 25 06:26:42 node102.yinzhengjie.org.cn mysqld_safe[7829]: 191025 06:26:42 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'. Oct 25 06:26:42 node102.yinzhengjie.org.cn mysqld_safe[7829]: 191025 06:26:42 mysqld_safe Starting mysqld daemon with databases from /va.../mysql Oct 25 06:26:44 node102.yinzhengjie.org.cn systemd[1]: Started MariaDB database server. Hint: Some lines were ellipsized, use -l to show in full. [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# ps aux | grep mariadb | grep -v grep #查看Mariadb服務的mariadb進程是否存在 mysql 7991 0.0 2.0 968788 79532 ? Sl 06:26 0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/li b64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock[root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# ss -ntl #咱們發現mariadb的3306端口啓動成功了,mariadb不愧是MySQL的一個分支,連默認的服務端口都一致 State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 50 *:3306 *:* LISTEN 0 128 *:22 *:* LISTEN 0 128 :::22 :::* [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# yum -y install psmisc #安裝pstree命令行工具 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.nju.edu.cn * extras: mirrors.nju.edu.cn * updates: mirrors.nju.edu.cn Resolving Dependencies --> Running transaction check ---> Package psmisc.x86_64 0:22.20-15.el7 will be updated ---> Package psmisc.x86_64 0:22.20-16.el7 will be an update --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================= Package Arch Version Repository Size ================================================================================================================================================= Updating: psmisc x86_64 22.20-16.el7 base 141 k Transaction Summary ================================================================================================================================================= Upgrade 1 Package Total download size: 141 k Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. psmisc-22.20-16.el7.x86_64.rpm | 141 kB 00:00:05 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : psmisc-22.20-16.el7.x86_64 1/2 Cleanup : psmisc-22.20-15.el7.x86_64 2/2 Verifying : psmisc-22.20-16.el7.x86_64 1/2 Verifying : psmisc-22.20-15.el7.x86_64 2/2 Updated: psmisc.x86_64 0:22.20-16.el7 Complete! [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# ps aux | grep mariadb | grep -v grep mysql 7991 0.0 2.0 968788 79532 ? Sl 06:26 0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/li b64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock[root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# pstree -p systemd(1)─┬─NetworkManager(2796)─┬─dhclient(2853) │ ├─{NetworkManager}(2825) │ └─{NetworkManager}(2828) ├─agetty(3088) ├─atd(2811) ├─auditd(2756)───{auditd}(2761) ├─crond(2823) ├─dbus-daemon(2791) ├─lvmetad(1523) ├─mysqld_safe(7829)───mysqld(7991)─┬─{mysqld}(7995) │ ├─{mysqld}(7996) │ ├─{mysqld}(7997) │ ├─{mysqld}(7998) │ ├─{mysqld}(7999) │ ├─{mysqld}(8000) │ ├─{mysqld}(8001) │ ├─{mysqld}(8002) │ ├─{mysqld}(8003) │ ├─{mysqld}(8004) │ ├─{mysqld}(8005) │ ├─{mysqld}(8006) │ ├─{mysqld}(8007) │ ├─{mysqld}(8008) │ ├─{mysqld}(8009) │ ├─{mysqld}(8010) │ ├─{mysqld}(8018) │ └─{mysqld}(8019) ├─polkitd(2786)─┬─{polkitd}(2797) │ ├─{polkitd}(2799) │ ├─{polkitd}(2809) │ ├─{polkitd}(2821) │ ├─{polkitd}(2824) │ └─{polkitd}(2826) ├─rsyslogd(3078)─┬─{rsyslogd}(3085) │ └─{rsyslogd}(3086) ├─sshd(3074)─┬─sshd(3812)───bash(3814)───pstree(8129) │ └─sshd(4296)───bash(4298) ├─systemd-journal(1497) ├─systemd-logind(2788) ├─systemd-udevd(1518) └─tuned(3073)─┬─{tuned}(3353) ├─{tuned}(3354) ├─{tuned}(3355) └─{tuned}(3368) [root@node102.yinzhengjie.org.cn ~]#
3>.鏈接mysql服務器
[root@node102.yinzhengjie.org.cn ~]# mysql #使用mysql命令行工具鏈接Mariadb數據庫,默認密碼爲空 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 4 Server version: 5.5.64-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)]> \h #查看幫助信息 General information about MariaDB can be found at http://mariadb.org List of all MySQL commands: Note that all text commands must be first on line and end with ';' ? (\?) Synonym for `help'. clear (\c) Clear the current input statement. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to mysql server, display result vertically. exit (\q) Exit mysql. Same as quit. go (\g) Send command to mysql server. help (\h) Display this help. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. print (\p) Print current command. prompt (\R) Change your mysql prompt. quit (\q) Quit mysql. rehash (\#) Rebuild completion hash. source (\.) Execute an SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement. For server side help, type 'help contents' MariaDB [(none)]> MariaDB [(none)]> QUIT #斷開Mariadb的鏈接 Bye [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# ll /var/lib/mysql/mysql.sock #默認的本地socket鏈接文件 srwxrwxrwx 1 mysql mysql 0 Oct 25 06:26 /var/lib/mysql/mysql.sock [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# mysql -S /var/lib/mysql/mysql.sock #使用"-S"指定默認的本地socket鏈接文件,默認路徑在"/var/lib/mysql/mysql.sock",若是沒有修改默認路徑我們能夠不指定。 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 6 Server version: 5.5.64-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)]> help General information about MariaDB can be found at http://mariadb.org List of all MySQL commands: Note that all text commands must be first on line and end with ';' ? (\?) Synonym for `help'. clear (\c) Clear the current input statement. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to mysql server, display result vertically. exit (\q) Exit mysql. Same as quit. go (\g) Send command to mysql server. help (\h) Display this help. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. print (\p) Print current command. prompt (\R) Change your mysql prompt. quit (\q) Quit mysql. rehash (\#) Rebuild completion hash. source (\.) Execute an SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement. For server side help, type 'help contents' MariaDB [(none)]> EXIT Bye [root@node102.yinzhengjie.org.cn ~]#
4>.MariaDB客戶端(使用和MySQL服務同樣的mysql客戶端鏈接工具)命令
[root@node102.yinzhengjie.org.cn ~]# mysql --help #查看mysql命令的幫助信息 mysql Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Usage: mysql [OPTIONS] [database] Default options are read from the following files in the given order: /etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf The following groups are read: mysql client client-server client-mariadb The following options may be given as the first argument: --print-defaults Print the program argument list and exit. --no-defaults Don't read default options from any option file. The following specify which files/extra groups are read (specified before remaining options): --defaults-file=# Only read default options from the given file #. --defaults-extra-file=# Read this file after the global files are read. --defaults-group-suffix=# Additionally read default groups with # appended as a suffix. -?, --help Display this help and exit. -I, --help Synonym for -? --abort-source-on-error Abort 'source filename' operations in case of errors --auto-rehash Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash. (Defaults to on; use --skip-auto-rehash to disable.) -A, --no-auto-rehash No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. --auto-vertical-output Automatically switch to vertical output mode if the result is wider than the terminal width. -B, --batch Don't use history file. Disable interactive behavior. (Enables --silent.) --binary-as-hex Print binary data as hex --character-sets-dir=name Directory for character set files. --column-type-info Display column type information. -c, --comments Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments. -C, --compress Use compression in server/client protocol. -#, --debug[=#] This is a non-debug version. Catch this and exit. --debug-check Check memory and open file usage at exit. -T, --debug-info Print some debug info at exit. -D, --database=name Database to use. --default-character-set=name Set the default character set. --delimiter=name Delimiter to be used. -e, --execute=name Execute command and quit. (Disables --force and history file.) -E, --vertical Print the output of a query (rows) vertically. -f, --force Continue even if we get an SQL error. Sets abort-source-on-error to 0 -G, --named-commands Enable named commands. Named commands mean this program's internal commands; see mysql> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default. -i, --ignore-spaces Ignore space after function names. --init-command=name SQL Command to execute when connecting to MySQL server. Will automatically be re-executed when reconnecting. --local-infile Enable/disable LOAD DATA LOCAL INFILE. -b, --no-beep Turn off beep on error. -h, --host=name Connect to host. -H, --html Produce HTML output. -X, --xml Produce XML output. --line-numbers Write line numbers for errors. (Defaults to on; use --skip-line-numbers to disable.) -L, --skip-line-numbers Don't write line number for errors. -n, --unbuffered Flush buffer after each query. --column-names Write column names in results. (Defaults to on; use --skip-column-names to disable.) -N, --skip-column-names Don't write column names in results. --sigint-ignore Ignore SIGINT (CTRL-C). -o, --one-database Ignore statements except those that occur while the default database is the one named at the command line. --pager[=name] Pager to use to display results. If you don't supply an option, the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\h) also. This option does not work in batch mode. Disable with --disable-pager. This option is disabled by default. -p, --password[=name] Password to use when connecting to server. If password is not given it's asked from the tty. -P, --port=# Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default (3306). --progress-reports Get progress reports for long running commands (like ALTER TABLE) (Defaults to on; use --skip-progress-reports to disable.) --prompt=name Set the mysql prompt to this value. --protocol=name The protocol to use for connection (tcp, socket, pipe, memory). -q, --quick Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file. -r, --raw Write fields without conversion. Used with --batch. --reconnect Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default. (Defaults to on; use --skip-reconnect to disable.) -s, --silent Be more silent. Print results with a tab as separator, each row on new line. -S, --socket=name The socket file to use for connection. --ssl Enable SSL for connection (automatically enabled with other flags). --ssl-ca=name CA file in PEM format (check OpenSSL docs, implies --ssl). --ssl-capath=name CA directory (check OpenSSL docs, implies --ssl). --ssl-cert=name X509 cert in PEM format (implies --ssl). --ssl-cipher=name SSL cipher to use (implies --ssl). --ssl-key=name X509 key in PEM format (implies --ssl). --ssl-verify-server-cert Verify server's "Common Name" in its cert against hostname used when connecting. This option is disabled by default. -t, --table Output in table format. --tee=name Append everything into outfile. See interactive help (\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default. -u, --user=name User for login if not current user. -U, --safe-updates Only allow UPDATE and DELETE that uses keys. -U, --i-am-a-dummy Synonym for option --safe-updates, -U. -v, --verbose Write more. (-v -v -v gives the table output format). -V, --version Output version information and exit. -w, --wait Wait and retry if connection is down. --connect-timeout=# Number of seconds before connection timeout. --max-allowed-packet=# The maximum packet length to send to or receive from server. --net-buffer-length=# The buffer size for TCP/IP and socket communication. --select-limit=# Automatic limit for SELECT when using --safe-updates. --max-join-size=# Automatic limit for rows in a join when using --safe-updates. --secure-auth Refuse client connecting to server if it uses old (pre-4.1.1) protocol. --server-arg=name Send embedded server this as a parameter. --show-warnings Show warnings after every statement. --plugin-dir=name Directory for client-side plugins. --default-auth=name Default authentication client-side plugin to use. --binary-mode By default, ASCII '\0' is disallowed and '\r\n' is translated to '\n'. This switch turns off both features, and also turns off parsing of all clientcommands except \C and DELIMITER, in non-interactive mode (for input piped to mysql or loaded using the 'source' command). This is necessary when processing output from mysqlbinlog that may contain blobs. Variables (--variable-name=value) and boolean options {FALSE|TRUE} Value (after reading options) --------------------------------- ---------------------------------------- abort-source-on-error FALSE auto-rehash TRUE auto-vertical-output FALSE binary-as-hex FALSE character-sets-dir (No default value) column-type-info FALSE comments FALSE compress FALSE debug-check FALSE debug-info FALSE database (No default value) default-character-set auto delimiter ; vertical FALSE force FALSE named-commands FALSE ignore-spaces FALSE init-command (No default value) local-infile FALSE no-beep FALSE host (No default value) html FALSE xml FALSE line-numbers TRUE unbuffered FALSE column-names TRUE sigint-ignore FALSE port 0 progress-reports TRUE prompt \N [\d]> quick FALSE raw FALSE reconnect TRUE socket (No default value) ssl FALSE ssl-ca (No default value) ssl-capath (No default value) ssl-cert (No default value) ssl-cipher (No default value) ssl-key (No default value) ssl-verify-server-cert FALSE table FALSE user (No default value) safe-updates FALSE i-am-a-dummy FALSE connect-timeout 0 max-allowed-packet 16777216 net-buffer-length 16384 select-limit 1000 max-join-size 1000000 secure-auth FALSE show-warnings FALSE plugin-dir (No default value) default-auth (No default value) binary-mode FALSE [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# man mysql #共計988行,相對上面的幫助信息更全面。
MariaDB [(none)]> \h #查看幫助信息 General information about MariaDB can be found at http://mariadb.org List of all MySQL commands: Note that all text commands must be first on line and end with ';' ? (\?) Synonym for `help'. clear (\c) Clear the current input statement. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to mysql server, display result vertically. exit (\q) Exit mysql. Same as quit. go (\g) Send command to mysql server. help (\h) Display this help. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. print (\p) Print current command. prompt (\R) Change your mysql prompt. quit (\q) Quit mysql. rehash (\#) Rebuild completion hash. source (\.) Execute an SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement. For server side help, type 'help contents' MariaDB [(none)]>
MariaDB [(none)]> STATUS #從服務器獲取狀態信息。 -------------- mysql Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1 Connection id: 7 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server: MariaDB Server version: 5.5.64-MariaDB MariaDB Server Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: latin1 Db characterset: latin1 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /var/lib/mysql/mysql.sock Uptime: 37 min 5 sec Threads: 1 Questions: 17 Slow queries: 0 Opens: 0 Flush tables: 2 Open tables: 26 Queries per second avg: 0.007 -------------- MariaDB [(none)]>
MariaDB [(none)]> SYSTEM hostname #在mariaDB命令行調用Linux命令 node102.yinzhengjie.org.cn MariaDB [(none)]>
MariaDB [(none)]> prompt node102.yinzhengjie.org.cn[mariadb]--> #臨時修改當前命令行的提示符 PROMPT set to 'node102.yinzhengjie.org.cn[mariadb]-->' node102.yinzhengjie.org.cn[mariadb]--> node102.yinzhengjie.org.cn[mariadb]-->system free -h total used free shared buff/cache available Mem: 3.7G 175M 3.1G 8.6M 405M 3.3G Swap: 3.9G 0B 3.9G node102.yinzhengjie.org.cn[mariadb]--> node102.yinzhengjie.org.cn[mariadb]-->
[root@node102.yinzhengjie.org.cn ~]# mysql --prompt="\u@[\D]-->" #啓動MariDB客戶端時臨時指定命令行提示符 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 5.5.64-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. root@[Fri Oct 25 07:35:58 2019]--> root@[Fri Oct 25 07:35:59 2019]-->SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.00 sec) root@[Fri Oct 25 07:36:08 2019]-->QUIT Bye [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# grep -v ^# /etc/my.cnf #注意觀察"[mysql]"對應的屬性,將MariaDB客戶端的配置寫在這裏便可,這樣下此啓動mysql命令行工具時會自動加載該配置信息喲~ [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock symbolic-links=0 [mysqld_safe] log-error=/var/log/mariadb/mariadb.log pid-file=/var/run/mariadb/mariadb.pid !includedir /etc/my.cnf.d [mysql] prompt="\u@[\D]->" [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 12 Server version: 5.5.64-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. root@[Fri Oct 25 07:41:40 2019]-> root@[Fri Oct 25 07:41:41 2019]->SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ rows in set (0.00 sec) root@[Fri Oct 25 07:41:46 2019]->
MariaDB [(none)]> SELECT DATABASE(); +------------+ | DATABASE() | +------------+ | NULL | +------------+ 1 row in set (0.00 sec) MariaDB [(none)]> MariaDB [(none)]> USE mysql #切換到mysql數據庫 Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [mysql]> MariaDB [mysql]> SELECT DATABASE(); +------------+ | DATABASE() | +------------+ | mysql | +------------+ 1 row in set (0.00 sec) MariaDB [mysql]> MariaDB [mysql]>
5>.MariaDB程序
客戶端程序:
mysql: 交互式的CLI工具
mysqldump:備份工具,基於mysql協議向mysqld發起查詢請求,並將查得的全部數據轉換成insert等寫操做語句保存文本文件中
mysqladmin:基於mysql協議管理mysqld
mysqlimport:數據導入工具
MyISAM存儲引擎的管理工具:
myisamchk:檢查MyISAM庫
myisampack:打包MyISAM表,只讀
服務器端程序
mysqld_safe
mysqld
mysqld_multi 多實例 ,示例:mysqld_multi --example
[root@node102.yinzhengjie.org.cn ~]# mysqladmin -uroot -pyinzhengjie ping #使用mysqladmin檢測MySQL服務是否正常運行 mysqld is alive [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# mysqladmin -uroot -pyinzhengjie status #查看MySQL服務的狀態信息 Uptime: 12204 Threads: 3 Questions: 147 Slow queries: 0 Opens: 15 Flush tables: 2 Open tables: 41 Queries per second avg: 0.012 [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# mysqladmin -uroot -pyinzhengjie version #查看MySQL的版本信息 mysqladmin Ver 9.0 Distrib 5.5.64-MariaDB, for Linux on x86_64 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Server version 5.5.64-MariaDB Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/lib/mysql/mysql.sock Uptime: 3 hours 30 min 11 sec Threads: 3 Questions: 149 Slow queries: 0 Opens: 15 Flush tables: 2 Open tables: 41 Queries per second avg: 0.011 [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# mysqladmin -uroot -pyinzhengjie shutdown #使用mysqladmin工具關閉MySQL服務 [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# mysqladmin -uroot -pyinzhengjie ping mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)' Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists! [root@node102.yinzhengjie.org.cn ~]#
6>.MairaDB配置
偵聽3306/tcp端口能夠在綁定有一個或所有接口IP上 vim /etc/my.cnf [mysqld] skip-networking=1 關閉網絡鏈接,只偵聽本地客戶端, 全部和服務器的交互都經過一個socket實現,socket的配置存放在"/var/lib/mysql/mysql.sock",可在/etc/my.cnf修改
[root@node102.yinzhengjie.org.cn ~]# ss -ntl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 50 *:3306 *:* LISTEN 0 128 *:22 *:* LISTEN 0 128 :::22 :::* [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# grep -v ^# /etc/my.cnf #關閉網絡,將"skip-networking"的Value設置爲1便可。 [mysqld] skip-networking #關閉網絡,此處咱們只須要把該屬性寫在這裏就表示啓用了,除非你顯示指定其值爲0(表示不啓用),若是咱們這樣寫默認是啓用了 datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock symbolic-links=0 [mysqld_safe] log-error=/var/log/mariadb/mariadb.log pid-file=/var/run/mariadb/mariadb.pid !includedir /etc/my.cnf.d [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# systemctl restart mariadb #重啓服務,發現MySQL服務在正常運行可是並未對外暴漏端口。 [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# ps aux | grep mysql | grep -v grep #MySQL服務處於正常運行狀態 root 8556 0.0 0.1 234060 4184 pts/0 S+ 07:50 0:00 mysql mysql 10132 0.0 0.0 113308 1624 ? Ss 10:38 0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr mysql 10306 0.0 2.0 968688 81204 ? Sl 10:38 0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/li b64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sockroot 10342 0.0 0.1 234060 4180 pts/1 S+ 10:38 0:00 mysql -uroot -px xxxxxxxxx [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# ss -ntl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 128 :::22 :::* [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# mysql -uroot -pyinzhengjie #本機基於socket文件依舊是能夠正常訪問的喲~ Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 5.5.64-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)]> status -------------- mysql Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1 Connection id: 2 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server: MariaDB Server version: 5.5.64-MariaDB MariaDB Server Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: latin1 Db characterset: latin1 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /var/lib/mysql/mysql.sock Uptime: 19 sec Threads: 1 Questions: 4 Slow queries: 0 Opens: 0 Flush tables: 2 Open tables: 26 Queries per second avg: 0.210 -------------- MariaDB [(none)]>
四.通用二進制格式安裝MariaDB/MySQL過程
1>.下載mariadb軟件包
選擇你須要的版本進行下載,官網地址:https://mariadb.com/downloads/
2>.建立mysql帳號
[root@node103.yinzhengjie.org.cn ~]# getent passwd mysql [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# useradd -r -s /sbin/nologin -d /data/mysql -c 'MariaDB user' mysql #建立一個mysql系統用戶 [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# getent passwd mysql mysql:x:998:994:MariaDB user:/data/mysql:/sbin/nologin [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# install -d /data/mysql -o mysql -g mysql #建立目錄時同時指定屬主和屬組 [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# ll -d /data/mysql drwxr-xr-x 2 mysql mysql 6 Oct 25 19:29 /data/mysql [root@node103.yinzhengjie.org.cn ~]#
3>.解壓並建立mysql軟鏈接
[root@node103.yinzhengjie.org.cn ~]# rpm -q mysql #檢查本地是否已經安裝了MySQL服務 package mysql is not installed [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# rpm -q mariadb-server #檢查本地是否已經安裝了MariaDB服務 package mariadb-server is not installed [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# ll total 445728 -rw-r--r-- 1 root root 456423718 Oct 25 19:13 mariadb-10.2.19-linux-x86_64.tar.gz [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# tar xf mariadb-10.2.19-linux-x86_64.tar.gz -C /usr/local/ #將下載的mariadb的軟件包進行解壓 [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# ls /usr/local/ bin etc games harbor include lib lib64 libexec mariadb-10.2.19-linux-x86_64 sbin share src [root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# ls /usr/local/ bin etc games harbor include lib lib64 libexec mariadb-10.2.19-linux-x86_64 sbin share src [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# ln -s /usr/local/mariadb-10.2.19-linux-x86_64/ /usr/local/mysql #因爲二進制安裝包是由官方編譯安裝好的,並且官方編譯時指定的路徑爲"/usr/local/mysql",所以咱們這裏能夠爲其作一個軟鏈接 [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# ls /usr/local/ bin etc games harbor include lib lib64 libexec mariadb-10.2.19-linux-x86_64 mysql sbin share src [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# ll /usr/local/mysql lrwxrwxrwx 1 root root 40 Oct 25 19:17 /usr/local/mysql -> /usr/local/mariadb-10.2.19-linux-x86_64/ [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# ll /usr/local/mysql/ total 176 drwxrwxr-x 2 1021 1004 4096 Sep 23 2018 bin -rw-r--r-- 1 1021 1004 17987 Nov 13 2018 COPYING -rw-r--r-- 1 1021 1004 86263 Nov 13 2018 COPYING.thirdparty -rw-r--r-- 1 1021 1004 2354 Nov 13 2018 CREDITS drwxrwxr-x 3 1021 1004 18 Nov 13 2018 data -rw-r--r-- 1 1021 1004 8245 Nov 13 2018 EXCEPTIONS-CLIENT drwxrwxr-x 3 1021 1004 19 Nov 13 2018 include -rw-r--r-- 1 1021 1004 8694 Nov 13 2018 INSTALL-BINARY drwxrwxr-x 5 1021 1004 335 Sep 23 2018 lib drwxrwxr-x 4 1021 1004 30 Nov 13 2018 man drwxrwxr-x 11 1021 1004 4096 Nov 13 2018 mysql-test -rw-r--r-- 1 1021 1004 2469 Nov 13 2018 README.md -rw-r--r-- 1 1021 1004 19510 Nov 13 2018 README-wsrep drwxrwxr-x 2 1021 1004 30 Nov 13 2018 scripts drwxrwxr-x 32 1021 1004 4096 Nov 13 2018 share drwxrwxr-x 4 1021 1004 4096 Nov 13 2018 sql-bench drwxrwxr-x 3 1021 1004 275 Nov 13 2018 support-files [root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# ll /usr/local/mysql/ total 176 drwxrwxr-x 2 1021 1004 4096 Sep 23 2018 bin -rw-r--r-- 1 1021 1004 17987 Nov 13 2018 COPYING -rw-r--r-- 1 1021 1004 86263 Nov 13 2018 COPYING.thirdparty -rw-r--r-- 1 1021 1004 2354 Nov 13 2018 CREDITS drwxrwxr-x 3 1021 1004 18 Nov 13 2018 data -rw-r--r-- 1 1021 1004 8245 Nov 13 2018 EXCEPTIONS-CLIENT drwxrwxr-x 3 1021 1004 19 Nov 13 2018 include -rw-r--r-- 1 1021 1004 8694 Nov 13 2018 INSTALL-BINARY drwxrwxr-x 5 1021 1004 335 Sep 23 2018 lib drwxrwxr-x 4 1021 1004 30 Nov 13 2018 man drwxrwxr-x 11 1021 1004 4096 Nov 13 2018 mysql-test -rw-r--r-- 1 1021 1004 2469 Nov 13 2018 README.md -rw-r--r-- 1 1021 1004 19510 Nov 13 2018 README-wsrep drwxrwxr-x 2 1021 1004 30 Nov 13 2018 scripts drwxrwxr-x 32 1021 1004 4096 Nov 13 2018 share drwxrwxr-x 4 1021 1004 4096 Nov 13 2018 sql-bench drwxrwxr-x 3 1021 1004 275 Nov 13 2018 support-files [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# chown -R mysql:mysql /usr/local/mysql/ #將MySQL程序的全部者和所屬組受權給我們建立的mysql用戶。 [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# ll /usr/local/mysql/ total 176 drwxrwxr-x 2 mysql mysql 4096 Sep 23 2018 bin -rw-r--r-- 1 mysql mysql 17987 Nov 13 2018 COPYING -rw-r--r-- 1 mysql mysql 86263 Nov 13 2018 COPYING.thirdparty -rw-r--r-- 1 mysql mysql 2354 Nov 13 2018 CREDITS drwxrwxr-x 3 mysql mysql 18 Nov 13 2018 data -rw-r--r-- 1 mysql mysql 8245 Nov 13 2018 EXCEPTIONS-CLIENT drwxrwxr-x 3 mysql mysql 19 Nov 13 2018 include -rw-r--r-- 1 mysql mysql 8694 Nov 13 2018 INSTALL-BINARY drwxrwxr-x 5 mysql mysql 335 Sep 23 2018 lib drwxrwxr-x 4 mysql mysql 30 Nov 13 2018 man drwxrwxr-x 11 mysql mysql 4096 Nov 13 2018 mysql-test -rw-r--r-- 1 mysql mysql 2469 Nov 13 2018 README.md -rw-r--r-- 1 mysql mysql 19510 Nov 13 2018 README-wsrep drwxrwxr-x 2 mysql mysql 30 Nov 13 2018 scripts drwxrwxr-x 32 mysql mysql 4096 Nov 13 2018 share drwxrwxr-x 4 mysql mysql 4096 Nov 13 2018 sql-bench drwxrwxr-x 3 mysql mysql 275 Nov 13 2018 support-files [root@node103.yinzhengjie.org.cn ~]#
4>.初始化數據庫目錄的系統庫(建立數據庫文件)
[root@node103.yinzhengjie.org.cn ~]# ll /usr/local/mysql/scripts/ #mysql初始化數據庫腳本存放路徑 total 20 -rwxr-xr-x 1 1021 1004 18925 Nov 13 2018 mysql_install_db [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn /usr/local/mysql/scripts]# ./mysql_install_db --help #查看該命令的幫助信息 Usage: ./mysql_install_db [OPTIONS] --auth-root-authentication-method=normal|socket Chooses the authentication method for the created initial root user. The default is 'normal' to creates a root user that can login without password, which can be insecure. The alternative 'socket' allows only the system root user to login as MariaDB root; this requires the unix socket authentication plugin. --auth-root-socket-user=user Used with --auth-root-authentication-method=socket. It specifies the name of the MariaDB root account, as well as of the system account allowed to access it. Defaults to 'root'. --basedir=path The path to the MariaDB installation directory. --builddir=path If using --srcdir with out-of-directory builds, you will need to set this to the location of the build directory where built files reside. --cross-bootstrap For internal use. Used when building the MariaDB system tables on a different host than the target. --datadir=path The path to the MariaDB data directory. --defaults-extra-file=name Read this file after the global files are read. --defaults-file=name Only read default options from the given file name. --defaults-group-suffix=name In addition to the given groups, read also groups with this suffix --force Causes mysql_install_db to run even if DNS does not work. In that case, grant table entries that normally use hostnames will use IP addresses. --help Display this help and exit. --ldata=path The path to the MariaDB data directory. Same as --datadir. --no-defaults Don't read default options from any option file. --defaults-file=path Read only this configuration file. --rpm For internal use. This option is used by RPM files during the MariaDB installation process. --skip-auth-anonymous-user Do not install an unprivileged anonymous user. --skip-name-resolve Use IP addresses rather than hostnames when creating grant table entries. This option can be useful if your DNS does not work. --srcdir=path The path to the MariaDB source directory. This option uses the compiled binaries and support files within the source tree, useful for if you don't want to install MariaDB yet and just want to create the system tables. --user=user_name The login username to use for running mysqld. Files and directories created by mysqld will be owned by this user. You must be root to use this option. By default mysqld runs using your current login name and files and directories that it creates will be owned by you. All other options are passed to the mysqld program [root@node103.yinzhengjie.org.cn /usr/local/mysql/scripts]# [root@node103.yinzhengjie.org.cn /usr/local/mysql/scripts]#
[root@node103.yinzhengjie.org.cn ~]# ll /data/mysql total 0 [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn /usr/local/mysql]# pwd /usr/local/mysql [root@node103.yinzhengjie.org.cn /usr/local/mysql]# [root@node103.yinzhengjie.org.cn /usr/local/mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ Installing MariaDB/MySQL system tables in '/data/mysql/' ... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER ! To do so, start the server, then issue the following commands: './bin/mysqladmin' -u root password 'new-password' './bin/mysqladmin' -u root -h node103.yinzhengjie.org.cn password 'new-password' Alternatively you can run: './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. You can start the MariaDB daemon with: cd '.' ; ./bin/mysqld_safe --datadir='/data/mysql/' You can test the MariaDB daemon with mysql-test-run.pl cd './mysql-test' ; perl mysql-test-run.pl 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/ [root@node103.yinzhengjie.org.cn /usr/local/mysql]# [root@node103.yinzhengjie.org.cn /usr/local/mysql]# ll /data/mysql/ total 110620 -rw-rw---- 1 mysql mysql 16384 Oct 25 19:36 aria_log.00000001 -rw-rw---- 1 mysql mysql 52 Oct 25 19:36 aria_log_control -rw-rw---- 1 mysql mysql 938 Oct 25 19:36 ib_buffer_pool -rw-rw---- 1 mysql mysql 12582912 Oct 25 19:36 ibdata1 -rw-rw---- 1 mysql mysql 50331648 Oct 25 19:36 ib_logfile0 -rw-rw---- 1 mysql mysql 50331648 Oct 25 19:36 ib_logfile1 drwx------ 2 mysql root 4096 Oct 25 19:36 mysql drwx------ 2 mysql mysql 20 Oct 25 19:36 performance_schema drwx------ 2 mysql root 6 Oct 25 19:36 test [root@node103.yinzhengjie.org.cn /usr/local/mysql]# [root@node103.yinzhengjie.org.cn /usr/local/mysql]#
5>.自定義MySQL的配置文件
[root@node103.yinzhengjie.org.cn /usr/local/mysql]# pwd /usr/local/mysql [root@node103.yinzhengjie.org.cn /usr/local/mysql]# [root@node103.yinzhengjie.org.cn /usr/local/mysql]# ll support-files/ #該目錄爲MySQL存放的一些配置文件模板,僅供參考 total 84 -rwxr-xr-x 1 1021 1004 1153 Nov 13 2018 binary-configure -rw-r--r-- 1 1021 1004 1328 Nov 13 2018 magic -rw-r--r-- 1 1021 1004 4875 Nov 13 2018 my-huge.cnf #最大化的數據庫模板參數(要求內存1-2G),很顯然生產環境咱們須要繼續調參,由於默認的配置參數較保守 -rw-r--r-- 1 1021 1004 20042 Nov 13 2018 my-innodb-heavy-4G.cnf -rw-r--r-- 1 1021 1004 4862 Nov 13 2018 my-large.cnf #最小化的數據庫模板參數(要求內存呢64M) -rw-r--r-- 1 1021 1004 4876 Nov 13 2018 my-medium.cnf #適用於32M-64M的模板 -rw-r--r-- 1 1021 1004 2802 Nov 13 2018 my-small.cnf -rwxr-xr-x 1 1021 1004 1061 Nov 13 2018 mysqld_multi.server -rwxr-xr-x 1 1021 1004 918 Nov 13 2018 mysql-log-rotate -rwxr-xr-x 1 1021 1004 12166 Nov 13 2018 mysql.server #MySQL服務的啓動腳本 drwxrwxr-x 4 1021 1004 37 Nov 13 2018 policy -rw-r--r-- 1 1021 1004 3479 Nov 13 2018 wsrep.cnf -rwxr-xr-x 1 1021 1004 2230 Nov 13 2018 wsrep_notify [root@node103.yinzhengjie.org.cn /usr/local/mysql]# [root@node103.yinzhengjie.org.cn /usr/local/mysql]#
[root@node103.yinzhengjie.org.cn ~]# mkdir /etc/mysql [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# cp /usr/local/mysql/support-files/my-huge.cnf /etc/mysql/my.cnf #將模板文件拷貝到MySQL配置文件目錄中 [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# ll /etc/mysql/ total 8 -rw-r--r-- 1 root root 4909 Oct 25 19:50 my.cnf [root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# vim /etc/mysql/my.cnf [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# cat /etc/mysql/my.cnf | grep -v ^# #MySQL的默認模板配置文件須要修改個別參數方能用 [client] port = 3306 socket = /data/mysql/mysql.sock #客戶端和服務端的socket文件必須指向同一個文件 [mysqld] datadir=/data/mysql #指定MySQL數據庫存放目錄 port = 3306 socket = /data/mysql/mysql.sock #和client中的socket配置要一致喲 skip-external-locking key_buffer_size = 384M max_allowed_packet = 1M table_open_cache = 512 sort_buffer_size = 2M read_buffer_size = 2M read_rnd_buffer_size = 8M myisam_sort_buffer_size = 64M thread_cache_size = 8 query_cache_size = 32M thread_concurrency = 8 log-bin=mysql-bin server-id = 1 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [myisamchk] key_buffer_size = 256M sort_buffer_size = 256M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout [root@node103.yinzhengjie.org.cn ~]#
6>.準備服務腳本,並啓動MySQL服務
[root@node103.yinzhengjie.org.cn ~]# ls /etc/init.d/ functions netconsole network README [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld #將MySQL模板啓動腳本複製到"/etc/init.d"目錄下 [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# ls /etc/init.d/ functions mysqld netconsole network README [root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# chkconfig --list Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'. netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# chkconfig --add mysqld #將MySQL服務設置爲開機自啓動 [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# chkconfig --list Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'. mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# service mysqld start #啓動MySQL服務 Starting MariaDB.191025 20:07:17 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'. 191025 20:07:17 mysqld_safe Starting mysqld daemon with databases from /data/mysql [ OK ] [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# ss -ntl #檢查MySQL默認端口是否啓動 State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 80 :::3306 :::* LISTEN 0 128 :::22 :::* [root@node103.yinzhengjie.org.cn ~]#
7>.配置MySQL的環境變量(PATH)
[root@node103.yinzhengjie.org.cn ~]# ll /usr/local/mysql/bin/mysql -rwxr-xr-x 1 mysql mysql 12193132 Nov 13 2018 /usr/local/mysql/bin/mysql [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# ll /usr/local/mysql/bin/ | wc -l 59 [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# echo 'PATH=/usr/local/mysql/bin:$PATH' PATH=/usr/local/mysql/bin:$PATH [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh #配置MySQL程序的環境變量 [root@node103.yinzhengjie.org.cn ~]# [root@node103.yinzhengjie.org.cn ~]# source /etc/profile.d/mysql.sh #使環境變量當即生效 [root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# mysql #登陸mariaDB數據庫,默認是不須要密碼的 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 10.2.19-MariaDB-log 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)]> SHOW VARIABLES LIKE 'datadir'; +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | datadir | /data/mysql/ | +---------------+--------------+ 1 row in set (0.00 sec) MariaDB [(none)]>
8>.安全初始化(運行"mysql_secure_installation"腳本以提升安全性)
[root@node103.yinzhengjie.org.cn ~]# mysql #未運行"mysql_secure_installation"腳本以前 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 10.2.19-MariaDB-log 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 [(none)]> SELECT user,host,password,authentication_string from mysql.user; +------+----------------------------+----------+-----------------------+ | user | host | password | authentication_string | +------+----------------------------+----------+-----------------------+ | root | localhost | | | | root | node103.yinzhengjie.org.cn | | | | root | 127.0.0.1 | | | | root | ::1 | | | | | localhost | | | | | node103.yinzhengjie.org.cn | | | +------+----------------------------+----------+-----------------------+ 6 rows in set (0.00 sec) MariaDB [(none)]> MariaDB [(none)]> QUIT Bye [root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# mysql_secure_installation #運行該腳本,默認會去找'/tmp/mysql.sock'套接字鏈接MySQL數據庫 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! [root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# mysql -uroot -pyinzhengjie #運行"mysql_secure_installation"以後就得按照我們的配置輸入密碼 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 18 Server version: 10.2.19-MariaDB-log 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)]> SELECT user,host,password,authentication_string from mysql.user; +------+-----------+-------------------------------------------+-----------------------+ | user | host | password | authentication_string | +------+-----------+-------------------------------------------+-----------------------+ | root | localhost | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | | | root | 127.0.0.1 | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | | | root | ::1 | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 | | +------+-----------+-------------------------------------------+-----------------------+ 3 rows in set (0.00 sec) MariaDB [(none)]> MariaDB [(none)]>
9>.經過二進制安裝MySQL過程(步驟和安裝MariaDB相似)
博主推薦閱讀: https://www.cnblogs.com/yinzhengjie/p/10201038.html
五.源碼編譯安裝mariadb
1>.安裝編譯時須要的依賴包
[root@node104.yinzhengjie.org.cn ~]# yum -y install bison bison-devel zlib-devel libcurl-devel libarchive-devel boost-devel gcc gcc-c++ cmake ncurses-devel gnutls-devel libxml2-devel openssl-devel libevent-devel libaio-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.jdcloud.com * extras: mirror.jdcloud.com * updates: mirrors.huaweicloud.com Resolving Dependencies --> Running transaction check ---> Package bison.x86_64 0:3.0.4-2.el7 will be installed ---> Package bison-devel.x86_64 0:3.0.4-2.el7 will be installed ---> Package boost-devel.x86_64 0:1.53.0-27.el7 will be installed --> Processing Dependency: boost(x86-64) = 1.53.0-27.el7 for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_wserialization.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_wserialization-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_wave.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_wave-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_unit_test_framework.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_unit_test_framework-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_timer.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_timer-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_system.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_system-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_signals.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_signals-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_serialization.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_serialization-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_regex.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_regex-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_random.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_random-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_python.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_python-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_program_options.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_program_options-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_prg_exec_monitor.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_prg_exec_monitor-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_math_tr1l.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_math_tr1l-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_math_tr1f.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_math_tr1f-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_math_tr1.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_math_tr1-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_math_c99l.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_math_c99l-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_math_c99f.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_math_c99f-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_math_c99.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_math_c99-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_locale-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_iostreams.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_iostreams-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_graph.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_graph-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_filesystem.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_filesystem-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_date_time.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_date_time-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_context.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_context-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_chrono.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_chrono-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 --> Processing Dependency: libboost_atomic-mt.so.1.53.0()(64bit) for package: boost-devel-1.53.0-27.el7.x86_64 ---> Package cmake.x86_64 0:2.8.12.2-2.el7 will be installed --> Processing Dependency: libarchive.so.13()(64bit) for package: cmake-2.8.12.2-2.el7.x86_64 ---> Package gcc.x86_64 0:4.8.5-39.el7 will be installed --> Processing Dependency: libgomp = 4.8.5-39.el7 for package: gcc-4.8.5-39.el7.x86_64 --> Processing Dependency: cpp = 4.8.5-39.el7 for package: gcc-4.8.5-39.el7.x86_64 --> Processing Dependency: libgcc >= 4.8.5-39.el7 for package: gcc-4.8.5-39.el7.x86_64 --> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-4.8.5-39.el7.x86_64 --> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-4.8.5-39.el7.x86_64 ---> Package gcc-c++.x86_64 0:4.8.5-39.el7 will be installed --> Processing Dependency: libstdc++-devel = 4.8.5-39.el7 for package: gcc-c++-4.8.5-39.el7.x86_64 --> Processing Dependency: libstdc++ = 4.8.5-39.el7 for package: gcc-c++-4.8.5-39.el7.x86_64 ---> Package gnutls-devel.x86_64 0:3.3.29-9.el7_6 will be installed --> Processing Dependency: gnutls-dane(x86-64) = 3.3.29-9.el7_6 for package: gnutls-devel-3.3.29-9.el7_6.x86_64 --> Processing Dependency: gnutls-c++(x86-64) = 3.3.29-9.el7_6 for package: gnutls-devel-3.3.29-9.el7_6.x86_64 --> Processing Dependency: gnutls(x86-64) = 3.3.29-9.el7_6 for package: gnutls-devel-3.3.29-9.el7_6.x86_64 --> Processing Dependency: pkgconfig(p11-kit-1) for package: gnutls-devel-3.3.29-9.el7_6.x86_64 --> Processing Dependency: pkgconfig(nettle) for package: gnutls-devel-3.3.29-9.el7_6.x86_64 --> Processing Dependency: pkgconfig(libtasn1) for package: gnutls-devel-3.3.29-9.el7_6.x86_64 --> Processing Dependency: pkgconfig(hogweed) for package: gnutls-devel-3.3.29-9.el7_6.x86_64 --> Processing Dependency: libgnutlsxx.so.28()(64bit) for package: gnutls-devel-3.3.29-9.el7_6.x86_64 --> Processing Dependency: libgnutls.so.28()(64bit) for package: gnutls-devel-3.3.29-9.el7_6.x86_64 --> Processing Dependency: libgnutls-dane.so.0()(64bit) for package: gnutls-devel-3.3.29-9.el7_6.x86_64 ---> Package libaio-devel.x86_64 0:0.3.109-13.el7 will be installed ---> Package libarchive-devel.x86_64 0:3.1.2-12.el7 will be installed ---> Package libcurl-devel.x86_64 0:7.29.0-54.el7 will be installed --> Processing Dependency: libcurl = 7.29.0-54.el7 for package: libcurl-devel-7.29.0-54.el7.x86_64 ---> Package libevent-devel.x86_64 0:2.0.21-4.el7 will be installed --> Processing Dependency: libevent = 2.0.21-4.el7 for package: libevent-devel-2.0.21-4.el7.x86_64 --> Processing Dependency: libevent_pthreads-2.0.so.5()(64bit) for package: libevent-devel-2.0.21-4.el7.x86_64 --> Processing Dependency: libevent_openssl-2.0.so.5()(64bit) for package: libevent-devel-2.0.21-4.el7.x86_64 --> Processing Dependency: libevent_extra-2.0.so.5()(64bit) for package: libevent-devel-2.0.21-4.el7.x86_64 --> Processing Dependency: libevent_core-2.0.so.5()(64bit) for package: libevent-devel-2.0.21-4.el7.x86_64 --> Processing Dependency: libevent-2.0.so.5()(64bit) for package: libevent-devel-2.0.21-4.el7.x86_64 ---> Package libxml2-devel.x86_64 0:2.9.1-6.el7_2.3 will be installed --> Processing Dependency: xz-devel for package: libxml2-devel-2.9.1-6.el7_2.3.x86_64 ---> Package ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 will be installed ---> Package openssl-devel.x86_64 1:1.0.2k-19.el7 will be installed --> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-19.el7 for package: 1:openssl-devel-1.0.2k-19.el7.x86_64 --> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-19.el7.x86_64 ---> Package zlib-devel.x86_64 0:1.2.7-18.el7 will be installed --> Running transaction check ---> Package boost.x86_64 0:1.53.0-27.el7 will be installed --> Processing Dependency: boost-thread(x86-64) = 1.53.0-27.el7 for package: boost-1.53.0-27.el7.x86_64 ---> Package boost-atomic.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-chrono.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-context.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-date-time.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-filesystem.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-graph.x86_64 0:1.53.0-27.el7 will be installed --> Processing Dependency: libicuuc.so.50()(64bit) for package: boost-graph-1.53.0-27.el7.x86_64 --> Processing Dependency: libicui18n.so.50()(64bit) for package: boost-graph-1.53.0-27.el7.x86_64 --> Processing Dependency: libicudata.so.50()(64bit) for package: boost-graph-1.53.0-27.el7.x86_64 ---> Package boost-iostreams.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-locale.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-math.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-program-options.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-python.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-random.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-regex.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-serialization.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-signals.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-system.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-test.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-timer.x86_64 0:1.53.0-27.el7 will be installed ---> Package boost-wave.x86_64 0:1.53.0-27.el7 will be installed ---> Package cpp.x86_64 0:4.8.5-39.el7 will be installed ---> Package gnutls.x86_64 0:3.3.29-9.el7_6 will be installed --> Processing Dependency: trousers >= 0.3.11.2 for package: gnutls-3.3.29-9.el7_6.x86_64 --> Processing Dependency: libnettle.so.4()(64bit) for package: gnutls-3.3.29-9.el7_6.x86_64 --> Processing Dependency: libhogweed.so.2()(64bit) for package: gnutls-3.3.29-9.el7_6.x86_64 ---> Package gnutls-c++.x86_64 0:3.3.29-9.el7_6 will be installed ---> Package gnutls-dane.x86_64 0:3.3.29-9.el7_6 will be installed --> Processing Dependency: libunbound.so.2()(64bit) for package: gnutls-dane-3.3.29-9.el7_6.x86_64 ---> Package krb5-devel.x86_64 0:1.15.1-37.el7_7.2 will be installed --> Processing Dependency: libkadm5(x86-64) = 1.15.1-37.el7_7.2 for package: krb5-devel-1.15.1-37.el7_7.2.x86_64 --> Processing Dependency: krb5-libs(x86-64) = 1.15.1-37.el7_7.2 for package: krb5-devel-1.15.1-37.el7_7.2.x86_64 --> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-37.el7_7.2.x86_64 --> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-37.el7_7.2.x86_64 --> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-37.el7_7.2.x86_64 --> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-37.el7_7.2.x86_64 ---> Package libarchive.x86_64 0:3.1.2-12.el7 will be installed ---> Package libcurl.x86_64 0:7.29.0-51.el7 will be updated --> Processing Dependency: libcurl = 7.29.0-51.el7 for package: curl-7.29.0-51.el7.x86_64 ---> Package libcurl.x86_64 0:7.29.0-54.el7 will be an update ---> Package libevent.x86_64 0:2.0.21-4.el7 will be installed ---> Package libgcc.x86_64 0:4.8.5-36.el7 will be updated ---> Package libgcc.x86_64 0:4.8.5-39.el7 will be an update ---> Package libgomp.x86_64 0:4.8.5-36.el7 will be updated ---> Package libgomp.x86_64 0:4.8.5-39.el7 will be an update ---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed ---> Package libstdc++.x86_64 0:4.8.5-36.el7 will be updated ---> Package libstdc++.x86_64 0:4.8.5-39.el7 will be an update ---> Package libstdc++-devel.x86_64 0:4.8.5-39.el7 will be installed ---> Package libtasn1-devel.x86_64 0:4.10-1.el7 will be installed ---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed ---> Package nettle-devel.x86_64 0:2.7.1-8.el7 will be installed --> Processing Dependency: gmp-devel(x86-64) for package: nettle-devel-2.7.1-8.el7.x86_64 ---> Package openssl-libs.x86_64 1:1.0.2k-16.el7 will be updated --> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-16.el7 for package: 1:openssl-1.0.2k-16.el7.x86_64 ---> Package openssl-libs.x86_64 1:1.0.2k-19.el7 will be an update ---> Package p11-kit-devel.x86_64 0:0.23.5-3.el7 will be installed ---> Package xz-devel.x86_64 0:5.2.2-1.el7 will be installed --> Running transaction check ---> Package boost-thread.x86_64 0:1.53.0-27.el7 will be installed ---> Package curl.x86_64 0:7.29.0-51.el7 will be updated ---> Package curl.x86_64 0:7.29.0-54.el7 will be an update ---> Package gmp-devel.x86_64 1:6.0.0-15.el7 will be installed ---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed ---> Package krb5-libs.x86_64 0:1.15.1-34.el7 will be updated ---> Package krb5-libs.x86_64 0:1.15.1-37.el7_7.2 will be an update ---> Package libcom_err-devel.x86_64 0:1.42.9-16.el7 will be installed --> Processing Dependency: libcom_err(x86-64) = 1.42.9-16.el7 for package: libcom_err-devel-1.42.9-16.el7.x86_64 ---> Package libicu.x86_64 0:50.2-3.el7 will be installed ---> Package libkadm5.x86_64 0:1.15.1-37.el7_7.2 will be installed ---> Package libselinux-devel.x86_64 0:2.5-14.1.el7 will be installed --> Processing Dependency: libsepol-devel(x86-64) >= 2.5-10 for package: libselinux-devel-2.5-14.1.el7.x86_64 --> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-14.1.el7.x86_64 --> Processing Dependency: pkgconfig(libpcre) for package: libselinux-devel-2.5-14.1.el7.x86_64 ---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed ---> Package nettle.x86_64 0:2.7.1-8.el7 will be installed ---> Package openssl.x86_64 1:1.0.2k-16.el7 will be updated ---> Package openssl.x86_64 1:1.0.2k-19.el7 will be an update ---> Package trousers.x86_64 0:0.3.14-2.el7 will be installed ---> Package unbound-libs.x86_64 0:1.6.6-1.el7 will be installed --> Running transaction check ---> Package libcom_err.x86_64 0:1.42.9-13.el7 will be updated --> Processing Dependency: libcom_err(x86-64) = 1.42.9-13.el7 for package: e2fsprogs-1.42.9-13.el7.x86_64 --> Processing Dependency: libcom_err(x86-64) = 1.42.9-13.el7 for package: e2fsprogs-libs-1.42.9-13.el7.x86_64 --> Processing Dependency: libcom_err(x86-64) = 1.42.9-13.el7 for package: libss-1.42.9-13.el7.x86_64 ---> Package libcom_err.x86_64 0:1.42.9-16.el7 will be an update ---> Package libsepol-devel.x86_64 0:2.5-10.el7 will be installed ---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed --> Running transaction check ---> Package e2fsprogs.x86_64 0:1.42.9-13.el7 will be updated ---> Package e2fsprogs.x86_64 0:1.42.9-16.el7 will be an update ---> Package e2fsprogs-libs.x86_64 0:1.42.9-13.el7 will be updated ---> Package e2fsprogs-libs.x86_64 0:1.42.9-16.el7 will be an update ---> Package libss.x86_64 0:1.42.9-13.el7 will be updated ---> Package libss.x86_64 0:1.42.9-16.el7 will be an update --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================= Package Arch Version Repository Size ================================================================================================================================================= Installing: bison x86_64 3.0.4-2.el7 base 674 k bison-devel x86_64 3.0.4-2.el7 base 24 k boost-devel x86_64 1.53.0-27.el7 base 7.0 M cmake x86_64 2.8.12.2-2.el7 base 7.1 M gcc x86_64 4.8.5-39.el7 base 16 M gcc-c++ x86_64 4.8.5-39.el7 base 7.2 M gnutls-devel x86_64 3.3.29-9.el7_6 base 1.4 M libaio-devel x86_64 0.3.109-13.el7 base 13 k libarchive-devel x86_64 3.1.2-12.el7 base 115 k libcurl-devel x86_64 7.29.0-54.el7 base 302 k libevent-devel x86_64 2.0.21-4.el7 base 85 k libxml2-devel x86_64 2.9.1-6.el7_2.3 base 1.0 M ncurses-devel x86_64 5.9-14.20130511.el7_4 base 712 k openssl-devel x86_64 1:1.0.2k-19.el7 base 1.5 M zlib-devel x86_64 1.2.7-18.el7 base 50 k Installing for dependencies: boost x86_64 1.53.0-27.el7 base 33 k boost-atomic x86_64 1.53.0-27.el7 base 35 k boost-chrono x86_64 1.53.0-27.el7 base 44 k boost-context x86_64 1.53.0-27.el7 base 36 k boost-date-time x86_64 1.53.0-27.el7 base 52 k boost-filesystem x86_64 1.53.0-27.el7 base 68 k boost-graph x86_64 1.53.0-27.el7 base 136 k boost-iostreams x86_64 1.53.0-27.el7 base 61 k boost-locale x86_64 1.53.0-27.el7 base 251 k boost-math x86_64 1.53.0-27.el7 base 334 k boost-program-options x86_64 1.53.0-27.el7 base 156 k boost-python x86_64 1.53.0-27.el7 base 129 k boost-random x86_64 1.53.0-27.el7 base 39 k boost-regex x86_64 1.53.0-27.el7 base 300 k boost-serialization x86_64 1.53.0-27.el7 base 169 k boost-signals x86_64 1.53.0-27.el7 base 60 k boost-system x86_64 1.53.0-27.el7 base 40 k boost-test x86_64 1.53.0-27.el7 base 223 k boost-thread x86_64 1.53.0-27.el7 base 57 k boost-timer x86_64 1.53.0-27.el7 base 43 k boost-wave x86_64 1.53.0-27.el7 base 210 k cpp x86_64 4.8.5-39.el7 base 5.9 M gmp-devel x86_64 1:6.0.0-15.el7 base 181 k gnutls x86_64 3.3.29-9.el7_6 base 680 k gnutls-c++ x86_64 3.3.29-9.el7_6 base 34 k gnutls-dane x86_64 3.3.29-9.el7_6 base 36 k keyutils-libs-devel x86_64 1.5.8-3.el7 base 37 k krb5-devel x86_64 1.15.1-37.el7_7.2 updates 272 k libarchive x86_64 3.1.2-12.el7 base 319 k libcom_err-devel x86_64 1.42.9-16.el7 base 32 k libevent x86_64 2.0.21-4.el7 base 214 k libicu x86_64 50.2-3.el7 base 6.9 M libkadm5 x86_64 1.15.1-37.el7_7.2 updates 178 k libmpc x86_64 1.0.1-3.el7 base 51 k libselinux-devel x86_64 2.5-14.1.el7 base 187 k libsepol-devel x86_64 2.5-10.el7 base 77 k libstdc++-devel x86_64 4.8.5-39.el7 base 1.5 M libtasn1-devel x86_64 4.10-1.el7 base 75 k libverto-devel x86_64 0.2.5-4.el7 base 12 k mpfr x86_64 3.1.1-4.el7 base 203 k nettle x86_64 2.7.1-8.el7 base 327 k nettle-devel x86_64 2.7.1-8.el7 base 471 k p11-kit-devel x86_64 0.23.5-3.el7 base 24 k pcre-devel x86_64 8.32-17.el7 base 480 k trousers x86_64 0.3.14-2.el7 base 289 k unbound-libs x86_64 1.6.6-1.el7 base 405 k xz-devel x86_64 5.2.2-1.el7 base 46 k Updating for dependencies: curl x86_64 7.29.0-54.el7 base 270 k e2fsprogs x86_64 1.42.9-16.el7 base 700 k e2fsprogs-libs x86_64 1.42.9-16.el7 base 167 k krb5-libs x86_64 1.15.1-37.el7_7.2 updates 805 k libcom_err x86_64 1.42.9-16.el7 base 41 k libcurl x86_64 7.29.0-54.el7 base 222 k libgcc x86_64 4.8.5-39.el7 base 102 k libgomp x86_64 4.8.5-39.el7 base 158 k libss x86_64 1.42.9-16.el7 base 46 k libstdc++ x86_64 4.8.5-39.el7 base 305 k openssl x86_64 1:1.0.2k-19.el7 base 493 k openssl-libs x86_64 1:1.0.2k-19.el7 base 1.2 M Transaction Summary ================================================================================================================================================= Install 15 Packages (+47 Dependent packages) Upgrade ( 12 Dependent packages) Total download size: 69 M Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. (1/74): bison-devel-3.0.4-2.el7.x86_64.rpm | 24 kB 00:00:00 (2/74): boost-1.53.0-27.el7.x86_64.rpm | 33 kB 00:00:00 (3/74): boost-atomic-1.53.0-27.el7.x86_64.rpm | 35 kB 00:00:00 (4/74): boost-chrono-1.53.0-27.el7.x86_64.rpm | 44 kB 00:00:00 (5/74): boost-context-1.53.0-27.el7.x86_64.rpm | 36 kB 00:00:00 (6/74): boost-date-time-1.53.0-27.el7.x86_64.rpm | 52 kB 00:00:00 (7/74): boost-devel-1.53.0-27.el7.x86_64.rpm | 7.0 MB 00:00:01 (8/74): bison-3.0.4-2.el7.x86_64.rpm | 674 kB 00:00:05 (9/74): boost-graph-1.53.0-27.el7.x86_64.rpm | 136 kB 00:00:00 (10/74): boost-iostreams-1.53.0-27.el7.x86_64.rpm | 61 kB 00:00:00 (11/74): boost-locale-1.53.0-27.el7.x86_64.rpm | 251 kB 00:00:03 (12/74): boost-math-1.53.0-27.el7.x86_64.rpm | 334 kB 00:00:01 (13/74): boost-program-options-1.53.0-27.el7.x86_64.rpm | 156 kB 00:00:00 (14/74): boost-python-1.53.0-27.el7.x86_64.rpm | 129 kB 00:00:00 (15/74): boost-random-1.53.0-27.el7.x86_64.rpm | 39 kB 00:00:00 (16/74): boost-regex-1.53.0-27.el7.x86_64.rpm | 300 kB 00:00:00 (17/74): boost-serialization-1.53.0-27.el7.x86_64.rpm | 169 kB 00:00:00 (18/74): boost-signals-1.53.0-27.el7.x86_64.rpm | 60 kB 00:00:00 (19/74): boost-test-1.53.0-27.el7.x86_64.rpm | 223 kB 00:00:00 boost-filesystem-1.53.0-27.el7 FAILED http://mirrors.neusoft.edu.cn/centos/7.7.1908/os/x86_64/Packages/boost-filesystem-1.53.0-27.el7.x86_64.rpm: [Errno 12] Timeout on http://103.238. 48.2/mirrors.neusoft.edu.cn/centos/7.7.1908/os/x86_64/Packages/boost-filesystem-1.53.0-27.el7.x86_64.rpm: (28, 'Connection timed out after 30990 milliseconds')Trying other mirror. (20/74): boost-timer-1.53.0-27.el7.x86_64.rpm | 43 kB 00:00:00 (21/74): boost-thread-1.53.0-27.el7.x86_64.rpm | 57 kB 00:00:00 (22/74): cpp-4.8.5-39.el7.x86_64.rpm | 5.9 MB 00:00:01 (23/74): boost-wave-1.53.0-27.el7.x86_64.rpm | 210 kB 00:00:05 (24/74): cmake-2.8.12.2-2.el7.x86_64.rpm | 7.1 MB 00:00:06 boost-system-1.53.0-27.el7.x86 FAILED http://mirrors.neusoft.edu.cn/centos/7.7.1908/os/x86_64/Packages/boost-system-1.53.0-27.el7.x86_64.rpm: [Errno 12] Timeout on http://103.238.48.2 /mirrors.neusoft.edu.cn/centos/7.7.1908/os/x86_64/Packages/boost-system-1.53.0-27.el7.x86_64.rpm: (28, 'Connection timed out after 30989 milliseconds')Trying other mirror. (25/74): curl-7.29.0-54.el7.x86_64.rpm | 270 kB 00:00:00 (26/74): e2fsprogs-1.42.9-16.el7.x86_64.rpm | 700 kB 00:00:00 (27/74): e2fsprogs-libs-1.42.9-16.el7.x86_64.rpm | 167 kB 00:00:00 (28/74): gnutls-3.3.29-9.el7_6.x86_64.rpm | 680 kB 00:00:00 (29/74): gnutls-dane-3.3.29-9.el7_6.x86_64.rpm | 36 kB 00:00:00 (30/74): gnutls-c++-3.3.29-9.el7_6.x86_64.rpm | 34 kB 00:00:00 (31/74): gnutls-devel-3.3.29-9.el7_6.x86_64.rpm | 1.4 MB 00:00:00 (32/74): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm | 37 kB 00:00:00 (33/74): krb5-libs-1.15.1-37.el7_7.2.x86_64.rpm | 805 kB 00:00:00 (34/74): libaio-devel-0.3.109-13.el7.x86_64.rpm | 13 kB 00:00:00 (35/74): libarchive-3.1.2-12.el7.x86_64.rpm | 319 kB 00:00:00 (36/74): libarchive-devel-3.1.2-12.el7.x86_64.rpm | 115 kB 00:00:00 (37/74): libcom_err-1.42.9-16.el7.x86_64.rpm | 41 kB 00:00:00 (38/74): gmp-devel-6.0.0-15.el7.x86_64.rpm | 181 kB 00:00:01 (39/74): libcom_err-devel-1.42.9-16.el7.x86_64.rpm | 32 kB 00:00:00 (40/74): libcurl-devel-7.29.0-54.el7.x86_64.rpm | 302 kB 00:00:00 (41/74): libevent-2.0.21-4.el7.x86_64.rpm | 214 kB 00:00:00 (42/74): libevent-devel-2.0.21-4.el7.x86_64.rpm | 85 kB 00:00:00 (43/74): libgcc-4.8.5-39.el7.x86_64.rpm | 102 kB 00:00:00 (44/74): libgomp-4.8.5-39.el7.x86_64.rpm | 158 kB 00:00:00 (45/74): libcurl-7.29.0-54.el7.x86_64.rpm | 222 kB 00:00:00 (46/74): libkadm5-1.15.1-37.el7_7.2.x86_64.rpm | 178 kB 00:00:00 (47/74): libmpc-1.0.1-3.el7.x86_64.rpm | 51 kB 00:00:00 (48/74): libselinux-devel-2.5-14.1.el7.x86_64.rpm | 187 kB 00:00:00 (49/74): libicu-50.2-3.el7.x86_64.rpm | 6.9 MB 00:00:00 (50/74): libss-1.42.9-16.el7.x86_64.rpm | 46 kB 00:00:00 (51/74): libstdc++-4.8.5-39.el7.x86_64.rpm | 305 kB 00:00:00 (52/74): libstdc++-devel-4.8.5-39.el7.x86_64.rpm | 1.5 MB 00:00:00 (53/74): libsepol-devel-2.5-10.el7.x86_64.rpm | 77 kB 00:00:00 (54/74): libtasn1-devel-4.10-1.el7.x86_64.rpm | 75 kB 00:00:00 (55/74): libverto-devel-0.2.5-4.el7.x86_64.rpm | 12 kB 00:00:00 (56/74): libxml2-devel-2.9.1-6.el7_2.3.x86_64.rpm | 1.0 MB 00:00:00 (57/74): ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm | 712 kB 00:00:00 (58/74): mpfr-3.1.1-4.el7.x86_64.rpm | 203 kB 00:00:00 (59/74): nettle-2.7.1-8.el7.x86_64.rpm | 327 kB 00:00:00 (60/74): openssl-1.0.2k-19.el7.x86_64.rpm | 493 kB 00:00:00 (61/74): nettle-devel-2.7.1-8.el7.x86_64.rpm | 471 kB 00:00:00 (62/74): openssl-libs-1.0.2k-19.el7.x86_64.rpm | 1.2 MB 00:00:00 (63/74): openssl-devel-1.0.2k-19.el7.x86_64.rpm | 1.5 MB 00:00:00 (64/74): pcre-devel-8.32-17.el7.x86_64.rpm | 480 kB 00:00:00 (65/74): trousers-0.3.14-2.el7.x86_64.rpm | 289 kB 00:00:00 (66/74): unbound-libs-1.6.6-1.el7.x86_64.rpm | 405 kB 00:00:00 (67/74): p11-kit-devel-0.23.5-3.el7.x86_64.rpm | 24 kB 00:00:00 (68/74): xz-devel-5.2.2-1.el7.x86_64.rpm | 46 kB 00:00:00 (69/74): boost-filesystem-1.53.0-27.el7.x86_64.rpm | 68 kB 00:00:00 (70/74): boost-system-1.53.0-27.el7.x86_64.rpm | 40 kB 00:00:00 (71/74): zlib-devel-1.2.7-18.el7.x86_64.rpm | 50 kB 00:00:00 (72/74): krb5-devel-1.15.1-37.el7_7.2.x86_64.rpm | 272 kB 00:00:05 (73/74): gcc-c++-4.8.5-39.el7.x86_64.rpm | 7.2 MB 00:00:06 (74/74): gcc-4.8.5-39.el7.x86_64.rpm | 16 MB 00:00:13 ------------------------------------------------------------------------------------------------------------------------------------------------- Total 1.2 MB/s | 69 MB 00:00:57 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : libgcc-4.8.5-39.el7.x86_64 1/86 Updating : libstdc++-4.8.5-39.el7.x86_64 2/86 Updating : libcom_err-1.42.9-16.el7.x86_64 3/86 Installing : boost-system-1.53.0-27.el7.x86_64 4/86 Updating : krb5-libs-1.15.1-37.el7_7.2.x86_64 5/86 Updating : 1:openssl-libs-1.0.2k-19.el7.x86_64 6/86 Installing : boost-chrono-1.53.0-27.el7.x86_64 7/86 Installing : mpfr-3.1.1-4.el7.x86_64 8/86 Installing : nettle-2.7.1-8.el7.x86_64 9/86 Installing : libmpc-1.0.1-3.el7.x86_64 10/86 Updating : libcurl-7.29.0-54.el7.x86_64 11/86 Installing : boost-thread-1.53.0-27.el7.x86_64 12/86 Installing : boost-filesystem-1.53.0-27.el7.x86_64 13/86 Installing : boost-date-time-1.53.0-27.el7.x86_64 14/86 Installing : libicu-50.2-3.el7.x86_64 15/86 Installing : boost-regex-1.53.0-27.el7.x86_64 16/86 Installing : zlib-devel-1.2.7-18.el7.x86_64 17/86 Installing : boost-graph-1.53.0-27.el7.x86_64 18/86 Installing : boost-locale-1.53.0-27.el7.x86_64 19/86 Installing : boost-wave-1.53.0-27.el7.x86_64 20/86 Installing : boost-timer-1.53.0-27.el7.x86_64 21/86 Installing : libarchive-3.1.2-12.el7.x86_64 22/86 Installing : libevent-2.0.21-4.el7.x86_64 23/86 Installing : boost-context-1.53.0-27.el7.x86_64 24/86 Installing : boost-signals-1.53.0-27.el7.x86_64 25/86 Installing : boost-iostreams-1.53.0-27.el7.x86_64 26/86 Installing : boost-atomic-1.53.0-27.el7.x86_64 27/86 Installing : boost-serialization-1.53.0-27.el7.x86_64 28/86 Installing : boost-program-options-1.53.0-27.el7.x86_64 29/86 Installing : boost-test-1.53.0-27.el7.x86_64 30/86 Installing : boost-random-1.53.0-27.el7.x86_64 31/86 Installing : boost-math-1.53.0-27.el7.x86_64 32/86 Installing : boost-python-1.53.0-27.el7.x86_64 33/86 Installing : boost-1.53.0-27.el7.x86_64 34/86 Installing : cpp-4.8.5-39.el7.x86_64 35/86 Installing : trousers-0.3.14-2.el7.x86_64 36/86 Installing : gnutls-3.3.29-9.el7_6.x86_64 37/86 Installing : gnutls-c++-3.3.29-9.el7_6.x86_64 38/86 Updating : 1:openssl-1.0.2k-19.el7.x86_64 39/86 Installing : unbound-libs-1.6.6-1.el7.x86_64 40/86 Installing : gnutls-dane-3.3.29-9.el7_6.x86_64 41/86 Installing : libkadm5-1.15.1-37.el7_7.2.x86_64 42/86 Updating : libss-1.42.9-16.el7.x86_64 43/86 Updating : e2fsprogs-libs-1.42.9-16.el7.x86_64 44/86 Installing : libcom_err-devel-1.42.9-16.el7.x86_64 45/86 Installing : libstdc++-devel-4.8.5-39.el7.x86_64 46/86 Installing : xz-devel-5.2.2-1.el7.x86_64 47/86 Updating : libgomp-4.8.5-39.el7.x86_64 48/86 Installing : gcc-4.8.5-39.el7.x86_64 49/86 Installing : pcre-devel-8.32-17.el7.x86_64 50/86 Installing : 1:gmp-devel-6.0.0-15.el7.x86_64 51/86 Installing : nettle-devel-2.7.1-8.el7.x86_64 52/86 Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64 53/86 Installing : libtasn1-devel-4.10-1.el7.x86_64 54/86 Installing : p11-kit-devel-0.23.5-3.el7.x86_64 55/86 Installing : libsepol-devel-2.5-10.el7.x86_64 56/86 Installing : libselinux-devel-2.5-14.1.el7.x86_64 57/86 Installing : libverto-devel-0.2.5-4.el7.x86_64 58/86 Installing : krb5-devel-1.15.1-37.el7_7.2.x86_64 59/86 Installing : 1:openssl-devel-1.0.2k-19.el7.x86_64 60/86 Installing : gnutls-devel-3.3.29-9.el7_6.x86_64 61/86 Installing : gcc-c++-4.8.5-39.el7.x86_64 62/86 Installing : libxml2-devel-2.9.1-6.el7_2.3.x86_64 63/86 Updating : e2fsprogs-1.42.9-16.el7.x86_64 64/86 Installing : boost-devel-1.53.0-27.el7.x86_64 65/86 Installing : libevent-devel-2.0.21-4.el7.x86_64 66/86 Installing : cmake-2.8.12.2-2.el7.x86_64 67/86 Installing : libarchive-devel-3.1.2-12.el7.x86_64 68/86 Installing : libcurl-devel-7.29.0-54.el7.x86_64 69/86 Updating : curl-7.29.0-54.el7.x86_64 70/86 Installing : bison-3.0.4-2.el7.x86_64 71/86 Installing : libaio-devel-0.3.109-13.el7.x86_64 72/86 Installing : ncurses-devel-5.9-14.20130511.el7_4.x86_64 73/86 Installing : bison-devel-3.0.4-2.el7.x86_64 74/86 Cleanup : 1:openssl-1.0.2k-16.el7.x86_64 75/86 Cleanup : e2fsprogs-1.42.9-13.el7.x86_64 76/86 Cleanup : e2fsprogs-libs-1.42.9-13.el7.x86_64 77/86 Cleanup : libss-1.42.9-13.el7.x86_64 78/86 Cleanup : curl-7.29.0-51.el7.x86_64 79/86 Cleanup : libcurl-7.29.0-51.el7.x86_64 80/86 Cleanup : krb5-libs-1.15.1-34.el7.x86_64 81/86 Cleanup : 1:openssl-libs-1.0.2k-16.el7.x86_64 82/86 Cleanup : libstdc++-4.8.5-36.el7.x86_64 83/86 Cleanup : libgcc-4.8.5-36.el7.x86_64 84/86 Cleanup : libcom_err-1.42.9-13.el7.x86_64 85/86 Cleanup : libgomp-4.8.5-36.el7.x86_64 86/86 Verifying : libxml2-devel-2.9.1-6.el7_2.3.x86_64 1/86 Verifying : gcc-4.8.5-39.el7.x86_64 2/86 Verifying : 1:openssl-libs-1.0.2k-19.el7.x86_64 3/86 Verifying : libverto-devel-0.2.5-4.el7.x86_64 4/86 Verifying : zlib-devel-1.2.7-18.el7.x86_64 5/86 Verifying : libgcc-4.8.5-39.el7.x86_64 6/86 Verifying : boost-thread-1.53.0-27.el7.x86_64 7/86 Verifying : bison-devel-3.0.4-2.el7.x86_64 8/86 Verifying : boost-context-1.53.0-27.el7.x86_64 9/86 Verifying : boost-signals-1.53.0-27.el7.x86_64 10/86 Verifying : boost-date-time-1.53.0-27.el7.x86_64 11/86 Verifying : libss-1.42.9-16.el7.x86_64 12/86 Verifying : unbound-libs-1.6.6-1.el7.x86_64 13/86 Verifying : boost-chrono-1.53.0-27.el7.x86_64 14/86 Verifying : libsepol-devel-2.5-10.el7.x86_64 15/86 Verifying : libcurl-devel-7.29.0-54.el7.x86_64 16/86 Verifying : p11-kit-devel-0.23.5-3.el7.x86_64 17/86 Verifying : boost-locale-1.53.0-27.el7.x86_64 18/86 Verifying : libtasn1-devel-4.10-1.el7.x86_64 19/86 Verifying : boost-timer-1.53.0-27.el7.x86_64 20/86 Verifying : trousers-0.3.14-2.el7.x86_64 21/86 Verifying : boost-system-1.53.0-27.el7.x86_64 22/86 Verifying : keyutils-libs-devel-1.5.8-3.el7.x86_64 23/86 Verifying : 1:gmp-devel-6.0.0-15.el7.x86_64 24/86 Verifying : cmake-2.8.12.2-2.el7.x86_64 25/86 Verifying : gnutls-dane-3.3.29-9.el7_6.x86_64 26/86 Verifying : nettle-2.7.1-8.el7.x86_64 27/86 Verifying : libstdc++-4.8.5-39.el7.x86_64 28/86 Verifying : libarchive-3.1.2-12.el7.x86_64 29/86 Verifying : boost-devel-1.53.0-27.el7.x86_64 30/86 Verifying : libselinux-devel-2.5-14.1.el7.x86_64 31/86 Verifying : boost-iostreams-1.53.0-27.el7.x86_64 32/86 Verifying : e2fsprogs-1.42.9-16.el7.x86_64 33/86 Verifying : gnutls-3.3.29-9.el7_6.x86_64 34/86 Verifying : boost-graph-1.53.0-27.el7.x86_64 35/86 Verifying : gcc-c++-4.8.5-39.el7.x86_64 36/86 Verifying : 1:openssl-1.0.2k-19.el7.x86_64 37/86 Verifying : libevent-devel-2.0.21-4.el7.x86_64 38/86 Verifying : libmpc-1.0.1-3.el7.x86_64 39/86 Verifying : libicu-50.2-3.el7.x86_64 40/86 Verifying : e2fsprogs-libs-1.42.9-16.el7.x86_64 41/86 Verifying : boost-atomic-1.53.0-27.el7.x86_64 42/86 Verifying : boost-regex-1.53.0-27.el7.x86_64 43/86 Verifying : libcom_err-devel-1.42.9-16.el7.x86_64 44/86 Verifying : boost-serialization-1.53.0-27.el7.x86_64 45/86 Verifying : pcre-devel-8.32-17.el7.x86_64 46/86 Verifying : gnutls-c++-3.3.29-9.el7_6.x86_64 47/86 Verifying : ncurses-devel-5.9-14.20130511.el7_4.x86_64 48/86 Verifying : libarchive-devel-3.1.2-12.el7.x86_64 49/86 Verifying : libgomp-4.8.5-39.el7.x86_64 50/86 Verifying : boost-program-options-1.53.0-27.el7.x86_64 51/86 Verifying : boost-filesystem-1.53.0-27.el7.x86_64 52/86 Verifying : libevent-2.0.21-4.el7.x86_64 53/86 Verifying : boost-wave-1.53.0-27.el7.x86_64 54/86 Verifying : 1:openssl-devel-1.0.2k-19.el7.x86_64 55/86 Verifying : libaio-devel-0.3.109-13.el7.x86_64 56/86 Verifying : xz-devel-5.2.2-1.el7.x86_64 57/86 Verifying : mpfr-3.1.1-4.el7.x86_64 58/86 Verifying : libkadm5-1.15.1-37.el7_7.2.x86_64 59/86 Verifying : krb5-devel-1.15.1-37.el7_7.2.x86_64 60/86 Verifying : boost-test-1.53.0-27.el7.x86_64 61/86 Verifying : boost-random-1.53.0-27.el7.x86_64 62/86 Verifying : libstdc++-devel-4.8.5-39.el7.x86_64 63/86 Verifying : krb5-libs-1.15.1-37.el7_7.2.x86_64 64/86 Verifying : cpp-4.8.5-39.el7.x86_64 65/86 Verifying : boost-1.53.0-27.el7.x86_64 66/86 Verifying : libcom_err-1.42.9-16.el7.x86_64 67/86 Verifying : libcurl-7.29.0-54.el7.x86_64 68/86 Verifying : curl-7.29.0-54.el7.x86_64 69/86 Verifying : bison-3.0.4-2.el7.x86_64 70/86 Verifying : boost-math-1.53.0-27.el7.x86_64 71/86 Verifying : gnutls-devel-3.3.29-9.el7_6.x86_64 72/86 Verifying : nettle-devel-2.7.1-8.el7.x86_64 73/86 Verifying : boost-python-1.53.0-27.el7.x86_64 74/86 Verifying : libgcc-4.8.5-36.el7.x86_64 75/86 Verifying : libstdc++-4.8.5-36.el7.x86_64 76/86 Verifying : libss-1.42.9-13.el7.x86_64 77/86 Verifying : e2fsprogs-libs-1.42.9-13.el7.x86_64 78/86 Verifying : krb5-libs-1.15.1-34.el7.x86_64 79/86 Verifying : libcom_err-1.42.9-13.el7.x86_64 80/86 Verifying : 1:openssl-1.0.2k-16.el7.x86_64 81/86 Verifying : libcurl-7.29.0-51.el7.x86_64 82/86 Verifying : 1:openssl-libs-1.0.2k-16.el7.x86_64 83/86 Verifying : libgomp-4.8.5-36.el7.x86_64 84/86 Verifying : e2fsprogs-1.42.9-13.el7.x86_64 85/86 Verifying : curl-7.29.0-51.el7.x86_64 86/86 Installed: bison.x86_64 0:3.0.4-2.el7 bison-devel.x86_64 0:3.0.4-2.el7 boost-devel.x86_64 0:1.53.0-27.el7 cmake.x86_64 0:2.8.12.2-2.el7 gcc.x86_64 0:4.8.5-39.el7 gcc-c++.x86_64 0:4.8.5-39.el7 gnutls-devel.x86_64 0:3.3.29-9.el7_6 libaio-devel.x86_64 0:0.3.109-13.el7 libarchive-devel.x86_64 0:3.1.2-12.el7 libcurl-devel.x86_64 0:7.29.0-54.el7 libevent-devel.x86_64 0:2.0.21-4.el7 libxml2-devel.x86_64 0:2.9.1-6.el7_2.3 ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 openssl-devel.x86_64 1:1.0.2k-19.el7 zlib-devel.x86_64 0:1.2.7-18.el7 Dependency Installed: boost.x86_64 0:1.53.0-27.el7 boost-atomic.x86_64 0:1.53.0-27.el7 boost-chrono.x86_64 0:1.53.0-27.el7 boost-context.x86_64 0:1.53.0-27.el7 boost-date-time.x86_64 0:1.53.0-27.el7 boost-filesystem.x86_64 0:1.53.0-27.el7 boost-graph.x86_64 0:1.53.0-27.el7 boost-iostreams.x86_64 0:1.53.0-27.el7 boost-locale.x86_64 0:1.53.0-27.el7 boost-math.x86_64 0:1.53.0-27.el7 boost-program-options.x86_64 0:1.53.0-27.el7 boost-python.x86_64 0:1.53.0-27.el7 boost-random.x86_64 0:1.53.0-27.el7 boost-regex.x86_64 0:1.53.0-27.el7 boost-serialization.x86_64 0:1.53.0-27.el7 boost-signals.x86_64 0:1.53.0-27.el7 boost-system.x86_64 0:1.53.0-27.el7 boost-test.x86_64 0:1.53.0-27.el7 boost-thread.x86_64 0:1.53.0-27.el7 boost-timer.x86_64 0:1.53.0-27.el7 boost-wave.x86_64 0:1.53.0-27.el7 cpp.x86_64 0:4.8.5-39.el7 gmp-devel.x86_64 1:6.0.0-15.el7 gnutls.x86_64 0:3.3.29-9.el7_6 gnutls-c++.x86_64 0:3.3.29-9.el7_6 gnutls-dane.x86_64 0:3.3.29-9.el7_6 keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.15.1-37.el7_7.2 libarchive.x86_64 0:3.1.2-12.el7 libcom_err-devel.x86_64 0:1.42.9-16.el7 libevent.x86_64 0:2.0.21-4.el7 libicu.x86_64 0:50.2-3.el7 libkadm5.x86_64 0:1.15.1-37.el7_7.2 libmpc.x86_64 0:1.0.1-3.el7 libselinux-devel.x86_64 0:2.5-14.1.el7 libsepol-devel.x86_64 0:2.5-10.el7 libstdc++-devel.x86_64 0:4.8.5-39.el7 libtasn1-devel.x86_64 0:4.10-1.el7 libverto-devel.x86_64 0:0.2.5-4.el7 mpfr.x86_64 0:3.1.1-4.el7 nettle.x86_64 0:2.7.1-8.el7 nettle-devel.x86_64 0:2.7.1-8.el7 p11-kit-devel.x86_64 0:0.23.5-3.el7 pcre-devel.x86_64 0:8.32-17.el7 trousers.x86_64 0:0.3.14-2.el7 unbound-libs.x86_64 0:1.6.6-1.el7 xz-devel.x86_64 0:5.2.2-1.el7 Dependency Updated: curl.x86_64 0:7.29.0-54.el7 e2fsprogs.x86_64 0:1.42.9-16.el7 e2fsprogs-libs.x86_64 0:1.42.9-16.el7 krb5-libs.x86_64 0:1.15.1-37.el7_7.2 libcom_err.x86_64 0:1.42.9-16.el7 libcurl.x86_64 0:7.29.0-54.el7 libgcc.x86_64 0:4.8.5-39.el7 libgomp.x86_64 0:4.8.5-39.el7 libss.x86_64 0:1.42.9-16.el7 libstdc++.x86_64 0:4.8.5-39.el7 openssl.x86_64 1:1.0.2k-19.el7 openssl-libs.x86_64 1:1.0.2k-19.el7 Complete! [root@node104.yinzhengjie.org.cn ~]#
2>.作準備用戶和數據目錄
[root@node104.yinzhengjie.org.cn ~]# getent passwd mysql [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# useradd -r -s /sbin/nologin -d /data/mysql mysql #建立一個mysql系統用戶 [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# getent passwd mysql mysql:x:998:996::/data/mysql:/sbin/nologin [root@node104.yinzhengjie.org.cn ~]#
[root@node104.yinzhengjie.org.cn ~]# install -d /data/mysql -o mysql -g mysql #建立目錄同時指定屬主和屬組 [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# ll -d /data/mysql drwxr-xr-x 2 mysql mysql 6 Oct 26 07:58 /data/mysql [root@node104.yinzhengjie.org.cn ~]#
[root@node104.yinzhengjie.org.cn ~]# ll total 70176 -rw-r--r-- 1 root root 71856357 Oct 24 08:52 mariadb-10.2.19.tar.gz [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# tar xf mariadb-10.2.19.tar.gz #將源碼包解壓 [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# ll total 70180 drwxrwxr-x 33 1001 1001 4096 Nov 13 2018 mariadb-10.2.19 -rw-r--r-- 1 root root 71856357 Oct 24 08:52 mariadb-10.2.19.tar.gz [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# du -sh mariadb-10.2.19 506M mariadb-10.2.19 [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]#
3>.cmake編譯安裝
cmake的重要特性之一是其獨立於源碼(out-of-source)的編譯功能,即編譯工做能夠在另外一個指定的目錄中而非源碼目錄中進行,這能夠保證源碼目錄不受任何一次編譯的影響,所以在同一個源碼樹上能夠進行屢次不一樣的編譯,如針對於不一樣平臺編譯
編譯選項:
https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html
[root@node104.yinzhengjie.org.cn ~]# cd mariadb-10.2.19 [root@node104.yinzhengjie.org.cn ~/mariadb-10.2.19]# [root@node104.yinzhengjie.org.cn ~/mariadb-10.2.19]# cmake . \ > -DCMAKE_INSTALL_PREFIX=/app/mysql \ > -DMYSQL_DATADIR=/data/mysql/ \ > -DSYSCONFDIR=/etc/mysql \ > -DMYSQL_USER=mysql \ > -DWITH_INNOBASE_STORAGE_ENGINE=1 \ > -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ > -DWITH_PARTITION_STORAGE_ENGINE=1 \ > -DWITHOUT_MROONGA_STORAGE_ENGINE=1 \ > -DWITH_DEBUG=0 \ > -DWITH_READLINE=1 \ > -DWITH_SSL=system \ > -DWITH_ZLIB=system \ > -DWITH_LIBWRAP=0 \ > -DENABLED_LOCAL_INFILE=1 \ > -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \ > -DDEFAULT_CHARSET=utf8 \ > -DDEFAULT_COLLATION=utf8_general_ci #回車後須要等待編譯完成,須要等待一段時間
[root@node104.yinzhengjie.org.cn ~/mariadb-10.2.19]# make -j 4 && make install #多線程同時編譯安裝,根據機器性能而言,等待時間較長(約20~30分鐘)
4>.準備環境變量
[root@node104.yinzhengjie.org.cn ~]# echo 'PATH=/app/mysql/bin:$PATH' > /etc/profile.d/mysql.sh [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# cat /etc/profile.d/mysql.sh PATH=/app/mysql/bin:$PATH [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# . /etc/profile.d/mysql.sh [root@node104.yinzhengjie.org.cn ~]#
5>.生產數據庫文件
[root@node104.yinzhengjie.org.cn ~]# ll -d /data/mysql/ drwxr-xr-x 2 mysql mysql 6 Oct 26 07:58 /data/mysql/ [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# ll /data/mysql/ total 0 [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# cd /app/mysql/ [root@node104.yinzhengjie.org.cn /app/mysql]# [root@node104.yinzhengjie.org.cn /app/mysql]# scripts/mysql_install_db --datadir=/data/mysql/ --user=mysql Installing MariaDB/MySQL system tables in '/data/mysql/' ... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER ! To do so, start the server, then issue the following commands: './bin/mysqladmin' -u root password 'new-password' './bin/mysqladmin' -u root -h node104.yinzhengjie.org.cn password 'new-password' Alternatively you can run: './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. You can start the MariaDB daemon with: cd '.' ; ./bin/mysqld_safe --datadir='/data/mysql/' You can test the MariaDB daemon with mysql-test-run.pl cd './mysql-test' ; perl mysql-test-run.pl 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/ [root@node104.yinzhengjie.org.cn /app/mysql]# [root@node104.yinzhengjie.org.cn /app/mysql]# ll /data/mysql/ total 110620 -rw-rw---- 1 mysql mysql 16384 Oct 26 08:50 aria_log.00000001 -rw-rw---- 1 mysql mysql 52 Oct 26 08:50 aria_log_control -rw-rw---- 1 mysql mysql 938 Oct 26 08:50 ib_buffer_pool -rw-rw---- 1 mysql mysql 12582912 Oct 26 08:50 ibdata1 -rw-rw---- 1 mysql mysql 50331648 Oct 26 08:50 ib_logfile0 -rw-rw---- 1 mysql mysql 50331648 Oct 26 08:50 ib_logfile1 drwx------ 2 mysql root 4096 Oct 26 08:50 mysql drwx------ 2 mysql mysql 20 Oct 26 08:50 performance_schema drwx------ 2 mysql root 6 Oct 26 08:50 test [root@node104.yinzhengjie.org.cn /app/mysql]#
6>.準備配置文件
[root@node104.yinzhengjie.org.cn ~]# cp /app/mysql/support-files/my-huge.cnf /etc/my.cnf
7>.準備啓動腳本
[root@node104.yinzhengjie.org.cn ~]# cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld [root@node104.yinzhengjie.org.cn ~]# ll /etc/init.d/ total 52 -rw-r--r--. 1 root root 18281 Aug 24 2018 functions -rwxr-xr-x 1 root root 12132 Oct 26 08:52 mysqld -rwxr-xr-x. 1 root root 4569 Aug 24 2018 netconsole -rwxr-xr-x. 1 root root 7923 Aug 24 2018 network -rw-r--r--. 1 root root 1160 Oct 31 2018 README [root@node104.yinzhengjie.org.cn ~]#
8>.啓動服務
[root@node104.yinzhengjie.org.cn ~]# chkconfig --list Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'. netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# chkconfig --add mysqld #將MySQL服務添加爲開機自啓動 [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# chkconfig --list Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'. mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]#
[root@node104.yinzhengjie.org.cn ~]# service mysqld start Starting MariaDB.191026 08:55:07 mysqld_safe Logging to '/data/mysql/node104.yinzhengjie.org.cn.err'. 191026 08:55:07 mysqld_safe Starting mysqld daemon with databases from /data/mysql [ OK ] [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]# ss -ntl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 80 :::3306 :::* LISTEN 0 128 :::22 :::* [root@node104.yinzhengjie.org.cn ~]#
9>.安全初始化(運行"mysql_secure_installation"腳本以提升安全性)
[root@node104.yinzhengjie.org.cn ~]# 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] 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! [root@node104.yinzhengjie.org.cn ~]# [root@node104.yinzhengjie.org.cn ~]#