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

开发者社区> 数据库> 正文

CentOS6.8安装配置Mysql数据库(Dean的开发笔记-运维篇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:关闭


版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
数据库
使用钉钉扫一扫加入圈子
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

其他文章