Mysql安装、配置、优化

2019/12/9 16:08:48 人评论 次浏览 分类:学习教程

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Rrx_xue/article/details/103401935

Mysql安装、配置、优化

MySQL是一个关系型数据库管理系统,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件之一。

下载Mysql

1、通过网址https://dev.mysql.com/downloads/mysql/下载mysql

在这里插入图片描述

一、Mysql安装

普通安装及环境配置
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

使用yum进行mysql的安装

1、输入 yum list | grep mysql 命令

  [root@iZbp19m6s0kz1ktg5okuauZ ~]# yum list | grep mysql

查看yum服务器上mysql数据库的可下载版本信息

[root@iZbp19m6s0kz1ktg5okuauZ ~]# yum list | grep mysql
akonadi-mysql.x86_64                    1.9.2-4.el7                    base     
apr-util-mysql.x86_64                   1.5.2-6.el7                    base     
calligra-kexi-driver-mysql.x86_64       2.9.10-2.el7                   epel     
collectd-mysql.x86_64                   5.8.1-1.el7                    epel     
dmlite-plugins-mysql.x86_64             1.13.2-2.el7                   epel     
dovecot-mysql.x86_64                    1:2.2.36-3.el7_7.1             updates  
dpm-copy-server-mysql.x86_64            1.13.0-1.el7                   epel     
dpm-name-server-mysql.x86_64            1.13.0-1.el7                   epel     
dpm-server-mysql.x86_64                 1.13.0-1.el7                   epel     
dpm-srm-server-mysql.x86_64             1.13.0-1.el7                   epel     
dspam-mysql.x86_64                      3.10.2-12.el7                  epel     
exim-mysql.x86_64                       4.92.3-1.el7                   epel     
freeradius-mysql.x86_64                 3.0.13-10.el7_6                base     
fts-mysql.x86_64                        3.8.4-2.el7                    epel     
gnokii-smsd-mysql.x86_64                0.6.31-17.el7                  epel     
holland-mysql.noarch                    1.1.18-1.el7                   epel     
holland-mysqldump.noarch                1.1.18-1.el7                   epel     
holland-mysqllvm.noarch                 1.1.18-1.el7                   epel     
lfc-server-mysql.x86_64                 1.13.0-1.el7                   epel     
libdbi-dbd-mysql.x86_64                 0.8.3-16.el7                   base     
libgda-mysql.x86_64                     1:5.2.2-7.el7                  epel     
libnss-mysql.x86_64                     1.5-19.el7                     epel     
libodb-mysql.x86_64                     2.3.0-1.el7                    epel     
libodb-mysql-devel.x86_64               2.3.0-1.el7                    epel     
lighttpd-mod_authn_mysql.x86_64         1.4.54-1.el7                   epel     
lighttpd-mod_mysql_vhost.x86_64         1.4.54-1.el7                   epel     
mysql++.x86_64                          3.1.0-12.el7                   epel     
mysql++-devel.x86_64                    3.1.0-12.el7                   epel     
mysql++-manuals.x86_64                  3.1.0-12.el7                   epel     
mysql-connector-java.noarch             1:5.1.25-3.el7                 base     
mysql-connector-odbc.x86_64             5.2.5-8.el7                    base     
mysql-connector-python.noarch           1.1.6-1.el7                    epel     
mysql-mmm.noarch                        2.2.1-15.el7                   epel     
mysql-mmm-agent.noarch                  2.2.1-15.el7                   epel     
mysql-mmm-monitor.noarch                2.2.1-15.el7                   epel     
mysql-mmm-tools.noarch                  2.2.1-15.el7                   epel     
mysql-proxy.x86_64                      0.8.5-2.el7                    epel     
mysql-proxy-devel.x86_64                0.8.5-2.el7                    epel     
mysql-utilities.noarch                  1.3.6-1.el7                    epel     
mysqlreport.noarch                      3.5-11.el7                     epel     
mysqltuner.noarch                       1.7.13-1.git.59e5f40.el7       epel     
nagios-plugins-mysql.x86_64             2.2.2-2.20190926git1b8ad57.el7 epel     
nextcloud-mysql.noarch                  10.0.4-2.el7                   epel     
nodejs-mysql.noarch                     2.3.2-1.el7                    epel     
opendbx-mysql.x86_64                    1.4.6-6.el7                    epel     
opensips-mysql.x86_64                   1.10.5-4.el7                   epel     
owncloud-mysql.noarch                   9.1.5-1.el7                    epel     
pcp-pmda-mysql.x86_64                   4.3.2-3.el7_7                  updates  
pdns-backend-mysql.x86_64               4.1.11-1.el7                   epel     
perdition-mysql.x86_64                  2.2-2.el7                      epel     
perl-Test-mysqld.noarch                 0.21-1.el7                     epel     
php-mysql.x86_64                        5.4.16-46.1.el7_7              updates  
php-mysqlnd.x86_64                      5.4.16-46.1.el7_7              updates  
php-pear-MDB2-Driver-mysql.noarch       1.5.0-0.8.b4.el7               epel     
php-pear-MDB2-Driver-mysqli.noarch      1.5.0-0.8.b4.el7               epel     
poco-mysql.x86_64                       1.6.1-3.el7                    epel     
preludedb-mysql.x86_64                  5.0.0-1.el7                    epel     
proftpd-mysql.x86_64                    1.3.5e-7.el7                   epel     
python36-mysql.x86_64                   1.3.12-2.el7                   epel     
python36-mysql-debug.x86_64             1.3.12-2.el7                   epel     
qt-mysql.i686                           1:4.8.7-3.el7_6                base     
qt-mysql.x86_64                         1:4.8.7-3.el7_6                base     
qt5-qtbase-mysql.i686                   5.9.7-2.el7                    base     
qt5-qtbase-mysql.x86_64                 5.9.7-2.el7                    base     
redland-mysql.x86_64                    1.0.16-6.el7                   base     
root-sql-mysql.x86_64                   6.18.04-1.el7                  epel     
rsyslog-mysql.x86_64                    8.24.0-41.el7_7.2              updates  
soci-mysql.x86_64                       3.2.3-1.el7                    epel     
soci-mysql-devel.x86_64                 3.2.3-1.el7                    epel     
tcl-mysqltcl.x86_64                     3.052-1.el7                    epel     
voms-mysql-plugin.x86_64                3.1.7-5.el7                    epel     
wt-dbo-mysql.x86_64                     3.3.9-1.el7                    epel     
zabbix22-dbfiles-mysql.noarch           2.2.23-1.el7                   epel     
zabbix22-proxy-mysql.x86_64             2.2.23-1.el7                   epel     
zabbix22-server-mysql.x86_64            2.2.23-1.el7                   epel     
zabbix22-web-mysql.noarch               2.2.23-1.el7                   epel     
zabbix30-dbfiles-mysql.noarch           3.0.22-2.el7                   epel     
zabbix30-proxy-mysql.x86_64             3.0.22-2.el7                   epel     
zabbix30-server-mysql.x86_64            3.0.22-2.el7                   epel     
zabbix30-web-mysql.noarch               3.0.22-2.el7                   epel     
zabbix40-dbfiles-mysql.noarch           4.0.12-1.el7                   epel     
zabbix40-proxy-mysql.x86_64             4.0.12-1.el7                   epel     
zabbix40-server-mysql.x86_64            4.0.12-1.el7                   epel     
zabbix40-web-mysql.noarch               4.0.12-1.el7                   epel

2、输入 yum install -y mysql-server mysql mysql-devel 命令,安装mysql mysql-server mysql-devel

[root@iZbp19m6s0kz1ktg5okuauZ ~]# yum install -y mysql-server mysql mysql-devel

可以看到如下信息

Loaded plugins: fastestmirror
base                                                                                         | 3.6 kB  00:00:00     
epel                                                                                         | 5.4 kB  00:00:00     
extras                                                                                       | 2.9 kB  00:00:00     
updates                                                                                      | 2.9 kB  00:00:00     
(1/3): epel/x86_64/updateinfo                                                                | 1.0 MB  00:00:00     
(2/3): updates/7/x86_64/primary_db                                                           | 5.1 MB  00:00:00     
(3/3): epel/x86_64/primary_db                                                                | 6.9 MB  00:00:00     
Loading mirror speeds from cached hostfile
No package mysql-server available.
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.64-1.el7 will be installed
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.64-1.el7 for package: 1:mariadb-5.5.64-1.el7.x86_64
---> Package mariadb-devel.x86_64 1:5.5.64-1.el7 will be installed
--> Processing Dependency: openssl-devel(x86-64) for package: 1:mariadb-devel-5.5.64-1.el7.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be updated
---> Package mariadb-libs.x86_64 1:5.5.64-1.el7 will be an update
---> 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: zlib-devel(x86-64) 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
--> Running transaction check
---> 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 openssl-libs.x86_64 1:1.0.1e-60.el7_3.1 will be updated
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.1e-60.el7_3.1 for package: 1:openssl-1.0.1e-60.el7_3.1.x86_64
---> Package openssl-libs.x86_64 1:1.0.2k-19.el7 will be an update
---> Package zlib-devel.x86_64 0:1.2.7-18.el7 will be installed
--> Processing Dependency: zlib = 1.2.7-18.el7 for package: zlib-devel-1.2.7-18.el7.x86_64
--> Running transaction check
---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed
---> Package krb5-libs.x86_64 0:1.14.1-27.el7_3 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 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: libselinux(x86-64) = 2.5-14.1.el7 for package: libselinux-devel-2.5-14.1.el7.x86_64
--> 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 openssl.x86_64 1:1.0.1e-60.el7_3.1 will be updated
---> Package openssl.x86_64 1:1.0.2k-19.el7 will be an update
---> Package zlib.x86_64 0:1.2.7-17.el7 will be updated
---> Package zlib.x86_64 0:1.2.7-18.el7 will be an update
--> Running transaction check
---> Package libcom_err.x86_64 0:1.42.9-9.el7 will be updated
--> Processing Dependency: libcom_err(x86-64) = 1.42.9-9.el7 for package: libss-1.42.9-9.el7.x86_64
--> Processing Dependency: libcom_err(x86-64) = 1.42.9-9.el7 for package: e2fsprogs-libs-1.42.9-9.el7.x86_64
--> Processing Dependency: libcom_err(x86-64) = 1.42.9-9.el7 for package: e2fsprogs-1.42.9-9.el7.x86_64
---> Package libcom_err.x86_64 0:1.42.9-16.el7 will be an update
---> Package libselinux.x86_64 0:2.5-6.el7 will be updated
--> Processing Dependency: libselinux(x86-64) = 2.5-6.el7 for package: libselinux-python-2.5-6.el7.x86_64
--> Processing Dependency: libselinux(x86-64) = 2.5-6.el7 for package: libselinux-utils-2.5-6.el7.x86_64
---> Package libselinux.x86_64 0:2.5-14.1.el7 will be an update
--> Processing Dependency: libsepol(x86-64) >= 2.5-10 for package: libselinux-2.5-14.1.el7.x86_64
---> 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
--> Processing Dependency: pcre(x86-64) = 8.32-17.el7 for package: pcre-devel-8.32-17.el7.x86_64
--> Running transaction check
---> Package e2fsprogs.x86_64 0:1.42.9-9.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-9.el7 will be updated
---> Package e2fsprogs-libs.x86_64 0:1.42.9-16.el7 will be an update
---> Package libselinux-python.x86_64 0:2.5-6.el7 will be updated
---> Package libselinux-python.x86_64 0:2.5-14.1.el7 will be an update
---> Package libselinux-utils.x86_64 0:2.5-6.el7 will be updated
---> Package libselinux-utils.x86_64 0:2.5-14.1.el7 will be an update
---> Package libsepol.x86_64 0:2.5-6.el7 will be updated
---> Package libsepol.x86_64 0:2.5-10.el7 will be an update
---> Package libss.x86_64 0:1.42.9-9.el7 will be updated
---> Package libss.x86_64 0:1.42.9-16.el7 will be an update
---> Package pcre.x86_64 0:8.32-15.el7_2.1 will be updated
---> Package pcre.x86_64 0:8.32-17.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================
 Package                           Arch                 Version                         Repository             Size
====================================================================================================================
Installing:
 mariadb                           x86_64               1:5.5.64-1.el7                  base                  8.7 M
 mariadb-devel                     x86_64               1:5.5.64-1.el7                  base                  755 k
Installing for dependencies:
 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
 libcom_err-devel                  x86_64               1.42.9-16.el7                   base                   32 k
 libkadm5                          x86_64               1.15.1-37.el7_7.2               updates               178 k
 libselinux-devel                  x86_64               2.5-14.1.el7                    base                  187 k
 libsepol-devel                    x86_64               2.5-10.el7                      base                   77 k
 libverto-devel                    x86_64               0.2.5-4.el7                     base                   12 k
 openssl-devel                     x86_64               1:1.0.2k-19.el7                 base                  1.5 M
 pcre-devel                        x86_64               8.32-17.el7                     base                  480 k
 zlib-devel                        x86_64               1.2.7-18.el7                    base                   50 k
Updating for dependencies:
 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
 libselinux                        x86_64               2.5-14.1.el7                    base                  162 k
 libselinux-python                 x86_64               2.5-14.1.el7                    base                  235 k
 libselinux-utils                  x86_64               2.5-14.1.el7                    base                  151 k
 libsepol                          x86_64               2.5-10.el7                      base                  297 k
 libss                             x86_64               1.42.9-16.el7                   base                   46 k
 mariadb-libs                      x86_64               1:5.5.64-1.el7                  base                  759 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
 pcre                              x86_64               8.32-17.el7                     base                  422 k
 zlib                              x86_64               1.2.7-18.el7                    base                   90 k

Transaction Summary
====================================================================================================================
Install  2 Packages (+10 Dependent packages)
Upgrade             ( 14 Dependent packages)

Total download size: 18 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/26): e2fsprogs-libs-1.42.9-16.el7.x86_64.rpm                                              | 167 kB  00:00:00     
(2/26): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm                                           |  37 kB  00:00:00     
(3/26): e2fsprogs-1.42.9-16.el7.x86_64.rpm                                                   | 700 kB  00:00:00     
(4/26): libcom_err-1.42.9-16.el7.x86_64.rpm                                                  |  41 kB  00:00:00     
(5/26): libcom_err-devel-1.42.9-16.el7.x86_64.rpm                                            |  32 kB  00:00:00     
(6/26): krb5-devel-1.15.1-37.el7_7.2.x86_64.rpm                                              | 272 kB  00:00:00     
(7/26): krb5-libs-1.15.1-37.el7_7.2.x86_64.rpm                                               | 805 kB  00:00:00     
(8/26): libkadm5-1.15.1-37.el7_7.2.x86_64.rpm                                                | 178 kB  00:00:00     
(9/26): libselinux-2.5-14.1.el7.x86_64.rpm                                                   | 162 kB  00:00:00     
(10/26): libselinux-devel-2.5-14.1.el7.x86_64.rpm                                            | 187 kB  00:00:00     
(11/26): libselinux-utils-2.5-14.1.el7.x86_64.rpm                                            | 151 kB  00:00:00     
(12/26): libselinux-python-2.5-14.1.el7.x86_64.rpm                                           | 235 kB  00:00:00     
(13/26): libsepol-2.5-10.el7.x86_64.rpm                                                      | 297 kB  00:00:00     
(14/26): libss-1.42.9-16.el7.x86_64.rpm                                                      |  46 kB  00:00:00     
(15/26): libsepol-devel-2.5-10.el7.x86_64.rpm                                                |  77 kB  00:00:00     
(16/26): libverto-devel-0.2.5-4.el7.x86_64.rpm                                               |  12 kB  00:00:00     
(17/26): mariadb-devel-5.5.64-1.el7.x86_64.rpm                                               | 755 kB  00:00:00     
(18/26): mariadb-libs-5.5.64-1.el7.x86_64.rpm                                                | 759 kB  00:00:00     
(19/26): openssl-1.0.2k-19.el7.x86_64.rpm                                                    | 493 kB  00:00:00     
(20/26): openssl-devel-1.0.2k-19.el7.x86_64.rpm                                              | 1.5 MB  00:00:00     
(21/26): openssl-libs-1.0.2k-19.el7.x86_64.rpm                                               | 1.2 MB  00:00:00     
(22/26): pcre-8.32-17.el7.x86_64.rpm                                                         | 422 kB  00:00:00     
(23/26): pcre-devel-8.32-17.el7.x86_64.rpm                                                   | 480 kB  00:00:00     
(24/26): mariadb-5.5.64-1.el7.x86_64.rpm                                                     | 8.7 MB  00:00:00     
(25/26): zlib-1.2.7-18.el7.x86_64.rpm                                                        |  90 kB  00:00:00     
(26/26): zlib-devel-1.2.7-18.el7.x86_64.rpm                                                  |  50 kB  00:00:00     
--------------------------------------------------------------------------------------------------------------------
Total                                                                                21 MB/s |  18 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libcom_err-1.42.9-16.el7.x86_64                                                                 1/40 
  Updating   : zlib-1.2.7-18.el7.x86_64                                                                        2/40 
  Updating   : libsepol-2.5-10.el7.x86_64                                                                      3/40 
  Updating   : pcre-8.32-17.el7.x86_64                                                                         4/40 
  Updating   : libselinux-2.5-14.1.el7.x86_64                                                                  5/40 
  Updating   : 1:openssl-libs-1.0.2k-19.el7.x86_64                                                             6/40 
  Updating   : krb5-libs-1.15.1-37.el7_7.2.x86_64                                                              7/40 
  Updating   : 1:mariadb-libs-5.5.64-1.el7.x86_64                                                              8/40 
  Installing : libkadm5-1.15.1-37.el7_7.2.x86_64                                                               9/40 
  Installing : pcre-devel-8.32-17.el7.x86_64                                                                  10/40 
  Installing : libsepol-devel-2.5-10.el7.x86_64                                                               11/40 
  Installing : libselinux-devel-2.5-14.1.el7.x86_64                                                           12/40 
  Installing : zlib-devel-1.2.7-18.el7.x86_64                                                                 13/40 
  Installing : libcom_err-devel-1.42.9-16.el7.x86_64                                                          14/40 
  Updating   : libss-1.42.9-16.el7.x86_64                                                                     15/40 
  Updating   : e2fsprogs-libs-1.42.9-16.el7.x86_64                                                            16/40 
  Installing : libverto-devel-0.2.5-4.el7.x86_64                                                              17/40 
  Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                         18/40 
  Installing : krb5-devel-1.15.1-37.el7_7.2.x86_64                                                            19/40 
  Installing : 1:openssl-devel-1.0.2k-19.el7.x86_64                                                           20/40 
  Installing : 1:mariadb-devel-5.5.64-1.el7.x86_64                                                            21/40 
  Updating   : e2fsprogs-1.42.9-16.el7.x86_64                                                                 22/40 
  Installing : 1:mariadb-5.5.64-1.el7.x86_64                                                                  23/40 
  Updating   : 1:openssl-1.0.2k-19.el7.x86_64                                                                 24/40 
  Updating   : libselinux-python-2.5-14.1.el7.x86_64                                                          25/40 
  Updating   : libselinux-utils-2.5-14.1.el7.x86_64                                                           26/40 
  Cleanup    : 1:openssl-1.0.1e-60.el7_3.1.x86_64                                                             27/40 
  Cleanup    : e2fsprogs-1.42.9-9.el7.x86_64                                                                  28/40 
  Cleanup    : libselinux-utils-2.5-6.el7.x86_64                                                              29/40 
  Cleanup    : 1:mariadb-libs-5.5.52-1.el7.x86_64                                                             30/40 
  Cleanup    : krb5-libs-1.14.1-27.el7_3.x86_64                                                               31/40 
  Cleanup    : 1:openssl-libs-1.0.1e-60.el7_3.1.x86_64                                                        32/40 
  Cleanup    : e2fsprogs-libs-1.42.9-9.el7.x86_64                                                             33/40 
  Cleanup    : libss-1.42.9-9.el7.x86_64                                                                      34/40 
  Cleanup    : libselinux-python-2.5-6.el7.x86_64                                                             35/40 
  Cleanup    : libselinux-2.5-6.el7.x86_64                                                                    36/40 
  Cleanup    : pcre-8.32-15.el7_2.1.x86_64                                                                    37/40 
  Cleanup    : libsepol-2.5-6.el7.x86_64                                                                      38/40 
  Cleanup    : libcom_err-1.42.9-9.el7.x86_64                                                                 39/40 
  Cleanup    : zlib-1.2.7-17.el7.x86_64                                                                       40/40 
  Verifying  : 1:mariadb-libs-5.5.64-1.el7.x86_64                                                              1/40 
  Verifying  : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                          2/40 
  Verifying  : krb5-devel-1.15.1-37.el7_7.2.x86_64                                                             3/40 
  Verifying  : libcom_err-devel-1.42.9-16.el7.x86_64                                                           4/40 
  Verifying  : pcre-devel-8.32-17.el7.x86_64                                                                   5/40 
  Verifying  : pcre-8.32-17.el7.x86_64                                                                         6/40 
  Verifying  : libsepol-devel-2.5-10.el7.x86_64                                                                7/40 
  Verifying  : libverto-devel-0.2.5-4.el7.x86_64                                                               8/40 
  Verifying  : 1:mariadb-devel-5.5.64-1.el7.x86_64                                                             9/40 
  Verifying  : zlib-devel-1.2.7-18.el7.x86_64                                                                 10/40 
  Verifying  : 1:mariadb-5.5.64-1.el7.x86_64                                                                  11/40 
  Verifying  : zlib-1.2.7-18.el7.x86_64                                                                       12/40 
  Verifying  : e2fsprogs-1.42.9-16.el7.x86_64                                                                 13/40 
  Verifying  : krb5-libs-1.15.1-37.el7_7.2.x86_64                                                             14/40 
  Verifying  : libss-1.42.9-16.el7.x86_64                                                                     15/40 
  Verifying  : 1:openssl-1.0.2k-19.el7.x86_64                                                                 16/40 
  Verifying  : libsepol-2.5-10.el7.x86_64                                                                     17/40 
  Verifying  : 1:openssl-devel-1.0.2k-19.el7.x86_64                                                           18/40 
  Verifying  : libcom_err-1.42.9-16.el7.x86_64                                                                19/40 
  Verifying  : 1:openssl-libs-1.0.2k-19.el7.x86_64                                                            20/40 
  Verifying  : libselinux-python-2.5-14.1.el7.x86_64                                                          21/40 
  Verifying  : libselinux-utils-2.5-14.1.el7.x86_64                                                           22/40 
  Verifying  : e2fsprogs-libs-1.42.9-16.el7.x86_64                                                            23/40 
  Verifying  : libkadm5-1.15.1-37.el7_7.2.x86_64                                                              24/40 
  Verifying  : libselinux-devel-2.5-14.1.el7.x86_64                                                           25/40 
  Verifying  : libselinux-2.5-14.1.el7.x86_64                                                                 26/40 
  Verifying  : 1:openssl-1.0.1e-60.el7_3.1.x86_64                                                             27/40 
  Verifying  : libss-1.42.9-9.el7.x86_64                                                                      28/40 
  Verifying  : libsepol-2.5-6.el7.x86_64                                                                      29/40 
  Verifying  : libselinux-python-2.5-6.el7.x86_64                                                             30/40 
  Verifying  : 1:openssl-libs-1.0.1e-60.el7_3.1.x86_64                                                        31/40 
  Verifying  : libselinux-utils-2.5-6.el7.x86_64                                                              32/40 
  Verifying  : pcre-8.32-15.el7_2.1.x86_64                                                                    33/40 
  Verifying  : zlib-1.2.7-17.el7.x86_64                                                                       34/40 
  Verifying  : 1:mariadb-libs-5.5.52-1.el7.x86_64                                                             35/40 
  Verifying  : libselinux-2.5-6.el7.x86_64                                                                    36/40 
  Verifying  : libcom_err-1.42.9-9.el7.x86_64                                                                 37/40 
  Verifying  : e2fsprogs-libs-1.42.9-9.el7.x86_64                                                             38/40 
  Verifying  : e2fsprogs-1.42.9-9.el7.x86_64                                                                  39/40 
  Verifying  : krb5-libs-1.14.1-27.el7_3.x86_64                                                               40/40 

Installed:
  mariadb.x86_64 1:5.5.64-1.el7                         mariadb-devel.x86_64 1:5.5.64-1.el7                        

Dependency Installed:
  keyutils-libs-devel.x86_64 0:1.5.8-3.el7                   krb5-devel.x86_64 0:1.15.1-37.el7_7.2                  
  libcom_err-devel.x86_64 0:1.42.9-16.el7                    libkadm5.x86_64 0:1.15.1-37.el7_7.2                    
  libselinux-devel.x86_64 0:2.5-14.1.el7                     libsepol-devel.x86_64 0:2.5-10.el7                     
  libverto-devel.x86_64 0:0.2.5-4.el7                        openssl-devel.x86_64 1:1.0.2k-19.el7                   
  pcre-devel.x86_64 0:8.32-17.el7                            zlib-devel.x86_64 0:1.2.7-18.el7                       

Dependency Updated:
  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                        
  libselinux.x86_64 0:2.5-14.1.el7                         libselinux-python.x86_64 0:2.5-14.1.el7                  
  libselinux-utils.x86_64 0:2.5-14.1.el7                   libsepol.x86_64 0:2.5-10.el7                             
  libss.x86_64 0:1.42.9-16.el7                             mariadb-libs.x86_64 1:5.5.64-1.el7                       
  openssl.x86_64 1:1.0.2k-19.el7                           openssl-libs.x86_64 1:1.0.2k-19.el7                      
  pcre.x86_64 0:8.32-17.el7                                zlib.x86_64 0:1.2.7-18.el7  
  
Complete!                           

二、Mysql的配置

1、在安装完mysql数据库以后,会发现会多出一个mysqld的服务,这个就是数据库服务,输入 service mysqld start 命令就可以启动的mysql服务。
[root@iZbp19m6s0kz1ktg5okuauZ ~] # service mysqld start
初始化 MySQL 数据库: WARNING: The host 'xiaoluo' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
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 MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h xiaoluo password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script![确定]
正在启动 mysqld:                                            [确定]

2、第一次启动mysql服务器以后会提示非常多的信息,目的就是对mysql数据库进行初始化操作,重新启动mysql服务,就不会提示这么多信息了,如:

[root@iZbp19m6s0kz1ktg5okuauZ ~]# service mysqld start
停止 mysqld:                                             [确定]
正在启动 mysqld:                                          [确定]

3、在使用mysql数据库时,首先启动mysqld服务,可以使用chkconfig --list | grep mysqld 命令查看mysql服务是不是开机自动启动

[root@iZbp19m6s0kz1ktg5okuauZ ~]# chkconfig --list | grep mysqld
mysqld             0:关闭    1:关闭    2:关闭    3:关闭    4:关闭    5:关闭    6:关闭

4、如果mysqld服务并没有开机自动启动,可以使用 chkconfig mysqld on 命令来将其设置成开机启动

[root@iZbp19m6s0kz1ktg5okuauZ ~]# chkconfig mysqld on
[root@iZbp19m6s0kz1ktg5okuauZ ~]# chkconfig --list | grep mysqld
mysqld             0:关闭    1:关闭    2:关闭    3:关闭    4:关闭    5:关闭    6:关闭

5、mysql数据库安装以后只会有一个root管理员账号,此时root账号没有设置密码,在第一次启动mysql服务时,会进行数据库的一些初始化工作,会输出信息

/usr/bin/mysqladmin -u root password 'new-password'  // 为root账号设置密码

6、使用mysqladmin -u root password命令给root账号设置密码

[root@iZbp19m6s0kz1ktg5okuauZ ~]# mysqladmin -u root password
'root'

mysql的主配置文件是/etc/my.cnf /var/lib/mysql mysql数据库的数据库文件存放位置

[root@iZbp19m6s0kz1ktg5okuauZ ~]# ls my.cnf 
my.cnf

[root@iZbp19m6s0kz1ktg5okuauZ ~]# cat my.cnf 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

/var/lib/mysql mysql数据库的数据库文件存放位置

[root@iZbp19m6s0kz1ktg5okuauZ ~ ]# cd /var/lib/mysql/
[root@iZbp19m6s0kz1ktg5okuauZ mysql ]# ls -l
总用量 20488
-rw-rw----. 1 mysql mysql 10485760 4月   6 22:01 ibdata1
-rw-rw----. 1 mysql mysql  5242880 4月   6 22:01 ib_logfile0
-rw-rw----. 1 mysql mysql  5242880 4月   6 21:59 ib_logfile1
drwx------. 2 mysql mysql     4096 4月   6 21:59 mysql 
srwxrwxrwx. 1 mysql mysql        0 4月   6 22:01 mysql.sock
drwx------. 2 mysql mysql     4096 4月   6 21:59 test  

Mysql的优化

mysql的优化分为两方面:
  1. 服务器使用前的优化

  2. 服务使用中的优化

优化数据库对象

1、 根据需求选择正确的存储引擎,比如MySAM、InnoDB
2、 默认值尽可能的使用 NOT NULL
3、尽量少的使用VARCHAR,TEXT,BLOB这三个字段,效率,char>varchar>text
4、优化索引
普通索引、唯一索引、主索引、外键索引、复合索引
5、表的设计符合3NF

优化SQL

show status命令提高sql的执行频率

 show status like 'Com_%';

建立合适的索引

使用show status like 'Handler_%'命令查看索引的使用情况
show status like 'Handler_%';

"test_table"为测试表

 analyze table test_table;
check table test_table;
设置权限
mysql -r /var/lib/mysql
允许 root远程登录
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
优化mysql数据库性能参数

(1)、max_connections:
(2)、record_buffer:
(3)、key_buffer_size:
(4)、back_log:
(5)、interactive_timeout:
(6)、sort_buffer:
(7)、table_cache:
(8)、thread_cache_size:

相关资讯

    暂无相关的资讯...

共有访客发表了评论 网友评论

验证码: 看不清楚?
    -->