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

本文涉及的产品
RDS AI 助手,专业版
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
RDS MySQL DuckDB 分析主实例,基础系列 4核8GB
简介: 一、首先查看该操作系统上是否已经安装了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:关闭


相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
目录
相关文章
|
7月前
|
存储 关系型数据库 数据库
附部署代码|云数据库RDS 全托管 Supabase服务:小白轻松搞定开发AI应用
本文通过一个 Agentic RAG 应用的完整构建流程,展示了如何借助 RDS Supabase 快速搭建具备知识处理与智能决策能力的 AI 应用,展示从数据准备到应用部署的全流程,相较于传统开发模式效率大幅提升。
附部署代码|云数据库RDS 全托管 Supabase服务:小白轻松搞定开发AI应用
|
7月前
|
运维 监控 关系型数据库
AI 时代的 MySQL 数据库运维解决方案
本文探讨了大模型与MySQL数据库运维结合所带来的变革,介绍了构建结构化运维知识库、选择合适的大模型、设计Prompt调用策略、开发MCP Server以及建立监控优化闭环等关键步骤。通过将自然语言处理能力与数据库运维相结合,实现了故障智能诊断、SQL自动优化等功能,显著提升了MySQL运维效率和准确性。
661 18
|
8月前
|
人工智能 运维 关系型数据库
数据库运维:mysql 数据库迁移方法-mysqldump
本文介绍了MySQL数据库迁移的方法与技巧,重点探讨了数据量大小对迁移方式的影响。对于10GB以下的小型数据库,推荐使用mysqldump进行逻辑导出和source导入;10GB以上可考虑mydumper与myloader工具;100GB以上则建议物理迁移。文中还提供了统计数据库及表空间大小的SQL语句,并讲解了如何使用mysqldump导出存储过程、函数和数据结构。通过结合实际应用场景选择合适的工具与方法,可实现高效的数据迁移。
1408 1
|
5月前
|
存储 JSON 数据建模
鸿蒙 HarmonyOS NEXT端云一体化开发-云数据库篇
云数据库采用存储区、对象类型、对象三级结构,支持灵活的数据建模与权限管理,可通过AGC平台或本地项目初始化,实现数据的增删改查及端侧高效调用。
274 1
|
5月前
|
安全 关系型数据库 MySQL
CentOS 7 yum 安装 MySQL教程
在CentOS 7上安装MySQL 8,其实流程很清晰。首先通过官方Yum仓库来安装服务,然后启动并设为开机自启。最重要的环节是首次安全设置:需要先从日志里找到临时密码来登录,再修改成你自己的密码,并为远程连接创建用户和授权。最后,也别忘了在服务器防火墙上放行3306端口,这样远程才能连上。
1103 16
|
6月前
|
存储 关系型数据库 MySQL
在CentOS 8.x上安装Percona Xtrabackup工具备份MySQL数据步骤。
以上就是在CentOS8.x上通过Perconaxtabbackup工具对Mysql进行高效率、高可靠性、无锁定影响地实现在线快速全量及增加式数据库资料保存与恢复流程。通过以上流程可以有效地将Mysql相关资料按需求完成定期或不定期地保存与灾难恢复需求。
533 10
|
8月前
|
运维 监控 关系型数据库
AI 时代的 MySQL 数据库运维解决方案
本方案将大模型与MySQL运维深度融合,构建智能诊断、SQL优化与知识更新的自动化系统。通过知识库建设、大模型调用策略、MCP Server开发及监控闭环设计,全面提升数据库运维效率与准确性,实现从人工经验到智能决策的跃迁。
942 27
|
7月前
|
机器学习/深度学习 SQL 运维
数据库出问题还靠猜?教你一招用机器学习优化运维,稳得一批!
数据库出问题还靠猜?教你一招用机器学习优化运维,稳得一批!
262 4
|
7月前
|
存储 Linux Apache
在CentOS上配置SVN至Web目录的自动同步
通过上述配置,每次当SVN仓库中提交新的更改时,`post-commit`钩子将被触发,SVN仓库的内容会自动同步到指定的Web目录,从而实现代码的连续部署。
226 16