CentOS6.8安装配置Mysql数据库(Dean的开发笔记-运维篇1)

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: 一、首先查看该操作系统上是否已经安装了mysql数据库 [root@dean opt]# rpm -qa | grep mysql   mysql-libs-5.1.73-8.el6_8.
一、首先查看该操作系统上是否已经安装了mysql数据库
[root@dean opt]# rpm -qa | grep mysql  
mysql-libs-5.1.73-8.el6_8.x86_64  

二、查询yum上提供的mysql数据库可下载的版本
[root@dean opt]# yum list | grep mysql
mysql-libs.x86_64                           5.1.73-8.el6_8               @base  
apr-util-mysql.x86_64                       1.3.9-3.el6_0.1              base   
asterisk-mysql.x86_64                       1.8.32.3-2.el6               epel   
bacula-director-mysql.x86_64                5.0.0-13.el6                 base   
bacula-storage-mysql.x86_64                 5.0.0-13.el6                 base   
collectd-mysql.x86_64                       4.10.9-4.el6                 epel   
dmlite-plugins-mysql.x86_64                 0.8.6-2.el6                  epel   
dovecot-mysql.x86_64                        1:2.0.9-22.el6               base   
dpm-copy-server-mysql.x86_64                1.9.0-1.el6                  epel   
dpm-name-server-mysql.x86_64                1.9.0-1.el6                  epel   
dpm-server-mysql.x86_64                     1.9.0-1.el6                  epel   
dpm-srm-server-mysql.x86_64                 1.9.0-1.el6                  epel   
dspam-mysql.x86_64                          3.10.2-7.el6                 epel   
exim-mysql.x86_64                           4.89-1.el6                   epel   
freeradius-mysql.x86_64                     2.2.6-6.el6_7                base   
fts-mysql.i686                              3.6.8-1.el6                  epel   
fts-mysql.x86_64                            3.6.8-1.el6                  epel   
gnokii-smsd-mysql.x86_64                    0.6.30-2.el6                 epel   
holland-mysql.noarch                        1.0.14-3.el6                 epel   
holland-mysqldump.noarch                    1.0.14-3.el6                 epel   
holland-mysqllvm.noarch                     1.0.14-3.el6                 epel   
lfc-server-mysql.x86_64                     1.9.0-1.el6                  epel   
libdbi-dbd-mysql.x86_64                     0.8.3-5.1.el6                base   
libnss-mysql.i686                           1.5-12.el6                   epel   
libnss-mysql.x86_64                         1.5-12.el6                   epel   
libodb-mysql.i686                           2.3.0-1.el6                  epel   
libodb-mysql.x86_64                         2.3.0-1.el6                  epel   
libodb-mysql-devel.i686                     2.3.0-1.el6                  epel   
libodb-mysql-devel.x86_64                   2.3.0-1.el6                  epel   
lighttpd-mod_authn_mysql.x86_64             1.4.45-1.el6                 epel   
lighttpd-mod_mysql_vhost.x86_64             1.4.45-1.el6                 epel   
lua-sql-mysql.x86_64                        2.1.1-7.el6                  epel   
mod_auth_mysql.x86_64                       1:3.0.0-11.el6_0.1           base   
mydns-mysql.x86_64                          1.2.8.31-2.el6               epel   
mysql.x86_64                                5.1.73-8.el6_8               base   
mysql++.i686                                3.0.9-3.el6                  epel   
mysql++.x86_64                              3.0.9-3.el6                  epel   
mysql++-devel.i686                          3.0.9-3.el6                  epel   
mysql++-devel.x86_64                        3.0.9-3.el6                  epel   
mysql++-manuals.x86_64                      3.0.9-3.el6                  epel   
mysql-bench.x86_64                          5.1.73-8.el6_8               base   
mysql-connector-java.noarch                 1:5.1.17-6.el6               base   
mysql-connector-odbc.x86_64                 5.1.5r1144-7.el6             base   
mysql-connector-python.noarch               1.1.6-1.el6                  epel   
mysql-devel.i686                            5.1.73-8.el6_8               base   
mysql-devel.x86_64                          5.1.73-8.el6_8               base   
mysql-embedded.i686                         5.1.73-8.el6_8               base   
mysql-embedded.x86_64                       5.1.73-8.el6_8               base   
mysql-embedded-devel.i686                   5.1.73-8.el6_8               base   
mysql-embedded-devel.x86_64                 5.1.73-8.el6_8               base   
mysql-libs.i686                             5.1.73-8.el6_8               base   
mysql-mmm.noarch                            2.2.1-2.el6                  epel   
mysql-mmm-agent.noarch                      2.2.1-2.el6                  epel   
mysql-mmm-monitor.noarch                    2.2.1-2.el6                  epel   
mysql-mmm-tools.noarch                      2.2.1-2.el6                  epel   
mysql-proxy.i686                            0.8.5-2.el6                  epel   
mysql-proxy.x86_64                          0.8.5-2.el6                  epel   
mysql-proxy-devel.i686                      0.8.5-2.el6                  epel   
mysql-proxy-devel.x86_64                    0.8.5-2.el6                  epel   
mysql-server.x86_64                         5.1.73-8.el6_8               base   
mysql-test.x86_64                           5.1.73-8.el6_8               base   
mysql-utilities.noarch                      1.3.6-1.el6                  epel   
mysql_fdw_96.x86_64                         2.2.0-1.rhel6                pgdg96 
mysql_fdw_96-debuginfo.x86_64               2.2.0-1.rhel6                pgdg96 
mysqlcompat96.noarch                        0.0.7-1.rhel6                pgdg96 
mysqlreport.noarch                          3.5-4.el6                    epel   
mysqltuner.noarch                           1.6.0-1.el6                  epel   
nagios-plugins-mysql.x86_64                 2.1.4-3.el6                  epel   
ndoutils-mysql.x86_64                       1.5.2-1.el6                  epel   
nodejs-mysql.noarch                         2.0.0-alpha9.2.el6.2         epel   
opendbx-mysql.x86_64                        1.4.6-6.el6                  epel   
opensips-mysql.x86_64                       1.7.2-2.el6                  epel   
pam_mysql.i686                              1:0.7-0.12.rc1.el6           epel   
pam_mysql.x86_64                            1:0.7-0.12.rc1.el6           epel   
pcp-pmda-mysql.x86_64                       3.10.9-9.el6                 base   
pdns-backend-mysql.x86_64                   3.3.3-2.el6                  epel   
perl-Class-DBI-mysql.noarch                 1.00-7.el6                   epel   
perl-Test-mysqld.noarch                     0.17-3.el6                   epel   
php-mysql.x86_64                            5.3.3-49.el6                 base   
php-pear-MDB2-Driver-mysql.noarch           1.5.0-0.8.b4.el6             epel   
php-pear-MDB2-Driver-mysqli.noarch          1.5.0-0.8.b4.el6             epel   
poco-mysql.i686                             1.4.2p1-3.el6                epel   
poco-mysql.x86_64                           1.4.2p1-3.el6                epel   
proftpd-mysql.x86_64                        1.3.3g-10.el6                epel   
qt-mysql.i686                               1:4.6.2-28.el6_5             base   
qt-mysql.x86_64                             1:4.6.2-28.el6_5             base   
qt5-qtbase-mysql.i686                       5.6.1-3.el6                  epel   
qt5-qtbase-mysql.x86_64                     5.6.1-3.el6                  epel   
rekall-mysql.i686                           2.4.6-13.el6                 epel   
rekall-mysql.x86_64                         2.4.6-13.el6                 epel   
root-sql-mysql.x86_64                       5.34.36-1.el6                epel   
rsyslog-mysql.x86_64                        5.8.10-10.el6_6              base   
rsyslog7-mysql.x86_64                       7.4.10-7.el6                 base   
ruby-mysql.x86_64                           2.8.2-1.el6                  epel   
soci-mysql.i686                             3.2.2-2.el6                  epel   
soci-mysql.x86_64                           3.2.2-2.el6                  epel   
soci-mysql-devel.i686                       3.2.2-2.el6                  epel   
soci-mysql-devel.x86_64                     3.2.2-2.el6                  epel   
tcl-mysqltcl.x86_64                         3.052-1.el6                  epel   
voms-mysql-plugin.x86_64                    3.1.7-1.el6                  epel   
zabbix-proxy-mysql.x86_64                   1.8.22-1.el6                 epel   
zabbix-server-mysql.x86_64                  1.8.22-1.el6                 epel   
zabbix-web-mysql.noarch                     1.8.22-1.el6                 epel   
zabbix20-proxy-mysql.x86_64                 2.0.20-1.el6                 epel   
zabbix20-server-mysql.x86_64                2.0.20-1.el6                 epel   
zabbix20-web-mysql.noarch                   2.0.20-1.el6                 epel   
zabbix22-dbfiles-mysql.noarch               2.2.16-1.el6                 epel   
zabbix22-proxy-mysql.x86_64                 2.2.16-1.el6                 epel   
zabbix22-server-mysql.x86_64                2.2.16-1.el6                 epel   
zabbix22-web-mysql.noarch                   2.2.16-1.el6                 epel   


三、安装mysql 服务端
[root@dean opt]# yum install -y mysql-server mysql mysql-devel
已加载插件:fastestmirror, refresh-packagekit
设置安装进程
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
包 mysql-server-5.1.73-8.el6_8.x86_64 已安装并且是最新版本
包 mysql-5.1.73-8.el6_8.x86_64 已安装并且是最新版本
解决依赖关系
--> 执行事务检查
---> Package mysql-devel.x86_64 0:5.1.73-8.el6_8 will be 安装
--> 处理依赖关系 openssl-devel,它被软件包 mysql-devel-5.1.73-8.el6_8.x86_64 需要
--> 执行事务检查
---> Package openssl-devel.x86_64 0:1.0.1e-57.el6 will be 安装
--> 处理依赖关系 zlib-devel,它被软件包 openssl-devel-1.0.1e-57.el6.x86_64 需要
--> 处理依赖关系 krb5-devel,它被软件包 openssl-devel-1.0.1e-57.el6.x86_64 需要
--> 执行事务检查
---> Package krb5-devel.x86_64 0:1.10.3-65.el6 will be 安装
--> 处理依赖关系 libkadm5(x86-64) = 1.10.3-65.el6,它被软件包 krb5-devel-1.10.3-65.el6.x86_64 需要
--> 处理依赖关系 libselinux-devel,它被软件包 krb5-devel-1.10.3-65.el6.x86_64 需要
--> 处理依赖关系 libcom_err-devel,它被软件包 krb5-devel-1.10.3-65.el6.x86_64 需要
--> 处理依赖关系 keyutils-libs-devel,它被软件包 krb5-devel-1.10.3-65.el6.x86_64 需要
---> Package zlib-devel.x86_64 0:1.2.3-29.el6 will be 安装
--> 执行事务检查
---> Package keyutils-libs-devel.x86_64 0:1.4-5.el6 will be 安装
---> Package libcom_err-devel.x86_64 0:1.41.12-23.el6 will be 安装
---> Package libkadm5.x86_64 0:1.10.3-65.el6 will be 安装
---> Package libselinux-devel.x86_64 0:2.0.94-7.el6 will be 安装
--> 处理依赖关系 libsepol-devel >= 2.0.32-1,它被软件包 libselinux-devel-2.0.94-7.el6.x86_64 需要
--> 处理依赖关系 pkgconfig(libsepol),它被软件包 libselinux-devel-2.0.94-7.el6.x86_64 需要
--> 执行事务检查
---> Package libsepol-devel.x86_64 0:2.0.41-4.el6 will be 安装
--> 完成依赖关系计算

依赖关系解决

======================================================================================================================================================
 软件包                                      架构                           版本                                   仓库                          大小
======================================================================================================================================================
正在安装:
 mysql-devel                                 x86_64                         5.1.73-8.el6_8                         base                         130 k
为依赖而安装:
 keyutils-libs-devel                         x86_64                         1.4-5.el6                              base                          29 k
 krb5-devel                                  x86_64                         1.10.3-65.el6                          base                         504 k
 libcom_err-devel                            x86_64                         1.41.12-23.el6                         base                          33 k
 libkadm5                                    x86_64                         1.10.3-65.el6                          base                         143 k
 libselinux-devel                            x86_64                         2.0.94-7.el6                           base                         137 k
 libsepol-devel                              x86_64                         2.0.41-4.el6                           base                          64 k
 openssl-devel                               x86_64                         1.0.1e-57.el6                          base                         1.2 M
 zlib-devel                                  x86_64                         1.2.3-29.el6                           base                          44 k

事务概要
======================================================================================================================================================
Install       9 Package(s)

总下载量:2.2 M
Installed size: 5.5 M
下载软件包:
(1/9): keyutils-libs-devel-1.4-5.el6.x86_64.rpm                                                                                |  29 kB     00:00     
(2/9): krb5-devel-1.10.3-65.el6.x86_64.rpm                                                                                     | 504 kB     00:00     
(3/9): libcom_err-devel-1.41.12-23.el6.x86_64.rpm                                                                              |  33 kB     00:00     
(4/9): libkadm5-1.10.3-65.el6.x86_64.rpm                                                                                       | 143 kB     00:00     
(5/9): libselinux-devel-2.0.94-7.el6.x86_64.rpm                                                                                | 137 kB     00:00     
(6/9): libsepol-devel-2.0.41-4.el6.x86_64.rpm                                                                                  |  64 kB     00:00     
(7/9): mysql-devel-5.1.73-8.el6_8.x86_64.rpm                                                                                   | 130 kB     00:00     
(8/9): openssl-devel-1.0.1e-57.el6.x86_64.rpm                                                                                  | 1.2 MB     00:01     
(9/9): zlib-devel-1.2.3-29.el6.x86_64.rpm                                                                                      |  44 kB     00:00     
------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                  1.0 MB/s | 2.2 MB     00:02     
运行 rpm_check_debug 
执行事务测试
事务测试成功
执行事务
  正在安装   : zlib-devel-1.2.3-29.el6.x86_64                                                                                                     1/9 
  正在安装   : libcom_err-devel-1.41.12-23.el6.x86_64                                                                                             2/9 
  正在安装   : libkadm5-1.10.3-65.el6.x86_64                                                                                                      3/9 
  正在安装   : libsepol-devel-2.0.41-4.el6.x86_64                                                                                                 4/9 
  正在安装   : libselinux-devel-2.0.94-7.el6.x86_64                                                                                               5/9 
  正在安装   : keyutils-libs-devel-1.4-5.el6.x86_64                                                                                               6/9 
  正在安装   : krb5-devel-1.10.3-65.el6.x86_64                                                                                                    7/9 
  正在安装   : openssl-devel-1.0.1e-57.el6.x86_64                                                                                                 8/9 
  正在安装   : mysql-devel-5.1.73-8.el6_8.x86_64                                                                                                  9/9 
  Verifying  : keyutils-libs-devel-1.4-5.el6.x86_64                                                                                               1/9 
  Verifying  : libsepol-devel-2.0.41-4.el6.x86_64                                                                                                 2/9 
  Verifying  : openssl-devel-1.0.1e-57.el6.x86_64                                                                                                 3/9 
  Verifying  : krb5-devel-1.10.3-65.el6.x86_64                                                                                                    4/9 
  Verifying  : libkadm5-1.10.3-65.el6.x86_64                                                                                                      5/9 
  Verifying  : libcom_err-devel-1.41.12-23.el6.x86_64                                                                                             6/9 
  Verifying  : libselinux-devel-2.0.94-7.el6.x86_64                                                                                               7/9 
  Verifying  : mysql-devel-5.1.73-8.el6_8.x86_64                                                                                                  8/9 
  Verifying  : zlib-devel-1.2.3-29.el6.x86_64                                                                                                     9/9 

已安装:
  mysql-devel.x86_64 0:5.1.73-8.el6_8                                                                                                                 

作为依赖被安装:
  keyutils-libs-devel.x86_64 0:1.4-5.el6           krb5-devel.x86_64 0:1.10.3-65.el6                libcom_err-devel.x86_64 0:1.41.12-23.el6          
  libkadm5.x86_64 0:1.10.3-65.el6                  libselinux-devel.x86_64 0:2.0.94-7.el6           libsepol-devel.x86_64 0:2.0.41-4.el6              
  openssl-devel.x86_64 0:1.0.1e-57.el6             zlib-devel.x86_64 0:1.2.3-29.el6                

完毕!


四、启动mysql 服务
[root@dean opt]#  service mysqld start
Initializing MySQL database:  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 iZbp1hqpjpxyv2tw16das2Z 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!

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

五、给mysql数据库root 账号一个初始密码
[root@dean opt]# /usr/bin/mysqladmin -u root password '888888'

六、登录mysql数据库
[root@dean opt]# mysql -u root -p
Enter password: 

七、查看mysql数据版本
[root@dean opt]# rpm -qi mysql-server
Name        : mysql-server                 Relocations: (not relocatable)
Version     : 5.1.73                            Vendor: CentOS
Release     : 8.el6_8                       Build Date: 2017年01月27日 星期五 06时25分43秒
Install Date: 2017年06月01日 星期四 20时27分02秒      Build Host: c1bm.rdu2.centos.org
Group       : Applications/Databases        Source RPM: mysql-5.1.73-8.el6_8.src.rpm
Size        : 25884131                         License: GPLv2 with exceptions
Signature   : RSA/SHA1, 2017年01月27日 星期五 06时35分28秒, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://www.mysql.com
Summary     : The MySQL server and related files
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. This package contains
the MySQL server and some accompanying files and directories.

八、重启数据库
[root@dean opt]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

九、查看数据是否是开机自启动如果不是设置为开机自启动
[root@dean opt]#  chkconfig --list | grep mysqld
mysqld         	0:关闭	1:关闭	2:关闭	3:关闭	4:关闭	5:关闭	6:关闭
[root@dean opt]# chkconfig mysqld on
[root@dean opt]# chkconfig --list | grep mysql
mysqld         	0:关闭	1:关闭	2:启用	3:启用	4:启用	5:启用	6:关闭


相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
4天前
|
安全 关系型数据库 MySQL
CentOS7仅安装部署MySQL80客户端
通过上述步骤,你可以在CentOS 7上成功安装并配置MySQL 8.0客户端。这个过程确保你能够使用MySQL客户端工具连接和管理远程的MySQL数据库,而不需要在本地安装MySQL服务器。定期更新MySQL客户端可以确保你使用的是最新的功能和安全修复。
43 16
|
14天前
|
SQL 关系型数据库 API
HarmonyOs开发:关系型数据库封装之增删改查
每个方法都预留了多种调用方式,比如使用callback异步回调或者使用Promise异步回调,亦或者同步执行,大家在使用的过程中,可以根据自身业务需要进行选择性调用,也分别暴露了成功和失败的方法,可以针对性的判断在执行的过程中是否执行成功。
76 13
|
13天前
|
存储 前端开发 关系型数据库
鸿蒙开发:实现键值数据库存储
对于数据量比较的小的,我们直接选择轻量级的用户首选项方式即可,而对于数据量比较大的情况下,直接可以使用数据库,而对于相对来说,比较大的数据,我们就可以使用键值型数据库方式
|
13天前
|
SQL 存储 运维
从建模到运维:联犀如何完美融入时序数据库 TDengine 实现物联网数据流畅管理
本篇文章是“2024,我想和 TDengine 谈谈”征文活动的三等奖作品。文章从一个具体的业务场景出发,分析了企业在面对海量时序数据时的挑战,并提出了利用 TDengine 高效处理和存储数据的方法,帮助企业解决在数据采集、存储、分析等方面的痛点。通过这篇文章,作者不仅展示了自己对数据处理技术的理解,还进一步阐释了时序数据库在行业中的潜力与应用价值,为读者提供了很多实际的操作思路和技术选型的参考。
24 1
|
13天前
|
运维 监控 Cloud Native
云原生之运维监控实践:使用 taosKeeper 与 TDinsight 实现对 时序数据库TDengine 服务的监测告警
在数字化转型的过程中,监控与告警功能的优化对保障系统的稳定运行至关重要。本篇文章是“2024,我想和 TDengine 谈谈”征文活动的三等奖作品之一,详细介绍了如何利用 TDengine、taosKeeper 和 TDinsight 实现对 TDengine 服务的状态监控与告警功能。作者通过容器化安装 TDengine 和 Grafana,演示了如何配置 Grafana 数据源、导入 TDinsight 仪表板、以及如何设置告警规则和通知策略。欢迎大家阅读。
33 0
|
2月前
|
存储 SQL API
探索后端开发:构建高效API与数据库交互
【10月更文挑战第36天】在数字化时代,后端开发是连接用户界面和数据存储的桥梁。本文深入探讨如何设计高效的API以及如何实现API与数据库之间的无缝交互,确保数据的一致性和高性能。我们将从基础概念出发,逐步深入到实战技巧,为读者提供一个清晰的后端开发路线图。
|
2月前
|
运维 监控 关系型数据库
数据库管理中的自动化运维:挑战与解决方案
数据库管理中的自动化运维:挑战与解决方案
|
2月前
|
存储 缓存 NoSQL
2款使用.NET开发的数据库系统
2款使用.NET开发的数据库系统
|
2月前
|
存储 SQL 数据库
深入浅出后端开发之数据库优化实战
【10月更文挑战第35天】在软件开发的世界里,数据库性能直接关系到应用的响应速度和用户体验。本文将带你了解如何通过合理的索引设计、查询优化以及恰当的数据存储策略来提升数据库性能。我们将一起探索这些技巧背后的原理,并通过实际案例感受优化带来的显著效果。
60 4
|
2月前
|
关系型数据库 MySQL Linux
在 CentOS 7 中通过编译源码方式安装 MySQL 数据库的详细步骤,并与使用 RPM 包安装进行了对比
本文介绍了在 CentOS 7 中通过编译源码方式安装 MySQL 数据库的详细步骤,并与使用 RPM 包安装进行了对比。通过具体案例,读者可以了解如何准备环境、下载源码、编译安装、配置服务及登录 MySQL。编译源码安装虽然复杂,但提供了更高的定制性和灵活性,适用于需要高度定制的场景。
146 3