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

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: 一、首先查看该操作系统上是否已经安装了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:关闭


相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
6天前
|
关系型数据库 MySQL 数据库
《MySQL 简易速速上手小册》第1章:MySQL 基础和安装(2024 最新版)
《MySQL 简易速速上手小册》第1章:MySQL 基础和安装(2024 最新版)
28 4
|
16天前
|
关系型数据库 MySQL Linux
linux CentOS 7.4下 mysql5.7.20 密码改简单的方法
linux CentOS 7.4下 mysql5.7.20 密码改简单的方法
19 0
|
2天前
|
关系型数据库 MySQL Windows
windows安装MySQL5.7教程
windows安装MySQL5.7教程
8 0
|
2天前
|
SQL 存储 关系型数据库
MySQL Cluster集群安装及使用
MySQL Cluster集群安装及使用
|
2天前
|
关系型数据库 MySQL 中间件
【MySQL实战笔记】07 | 行锁功过:怎么减少行锁对性能的影响?-02 死锁和死锁检测
【4月更文挑战第19天】在高并发环境下,死锁发生在多个线程间循环等待资源时,导致无限期等待。MySQL中,死锁可通过`innodb_lock_wait_timeout`参数设置超时或`innodb_deadlock_detect`开启死锁检测来解决。默认的50s超时可能不适用于在线服务,而频繁检测会消耗大量CPU。应对热点行更新引发的性能问题,可以暂时关闭死锁检测(风险是产生大量超时),控制并发度,或通过分散记录减少锁冲突,例如将数据分拆到多行以降低死锁概率。
18 1
|
8天前
|
关系型数据库 MySQL Linux
Linux联网安装MySQL Server
Linux联网安装MySQL Server
21 0
|
9天前
|
关系型数据库 MySQL Linux
centos7安装mysql-带网盘安装包
centos7安装mysql-带网盘安装包
56 2
|
12天前
|
存储 关系型数据库 MySQL
【MySQL实战笔记】 04 | 深入浅出索引(上)-02
【4月更文挑战第9天】InnoDB数据库使用B+树作为索引模型,其中主键索引的叶子节点存储完整行数据,非主键索引则存储主键值。主键查询只需搜索一棵树,而非主键查询需两次搜索,因此推荐使用主键查询以提高效率。在插入新值时,B+树需要维护有序性,可能导致数据页分裂影响性能。自增主键在插入时可避免数据挪动和页分裂,且占用存储空间小,通常更为理想。然而,如果场景仅需唯一索引,可直接设为主键以减少查询步骤。
15 1
【MySQL实战笔记】 04 | 深入浅出索引(上)-02
|
13天前
|
关系型数据库 MySQL 数据库
Docker安装MySQL
Docker安装MySQL
28 1
|
13天前
|
关系型数据库 MySQL 数据安全/隐私保护
MySQL 安装及连接
MySQL 安装及连接
33 0