centos 安装mysql

1.下载
 安装前卸载libs
[root@node0 opt]# rpm -qa | grep mysql
mysql-libs-5.1.73-8.el6_8.x86_64
rpm -e --nodeps mysql-libs
用此命令删除
 
安装依赖:
yum install -y make 
yum install -y cmake
yum install -y gcc
yum install -y  gcc-c++
yum install -y  ncurses
yum install -y  ncurses-devel
查看版本用yum安装
[root@node0 opt]#  yum list | grep mysql
mysql-community-release.noarch              el7-5                       installed
apr-util-mysql.x86_64                       1.3.9-3.el6_0.1             base    
bacula-director-mysql.x86_64                5.0.0-13.el6                base    
bacula-storage-mysql.x86_64                 5.0.0-13.el6                base    
dovecot-mysql.x86_64                        1:2.0.9-22.el6              base    
freeradius-mysql.x86_64                     2.2.6-7.el6_9               updates 
libdbi-dbd-mysql.x86_64                     0.8.3-5.1.el6               base    
mod_auth_mysql.x86_64                       1:3.0.0-11.el6_0.1          base    
mysql.x86_64                                5.1.73-8.el6_8              base    
mysql-bench.x86_64                          5.1.73-8.el6_8              base    
mysql-community-bench.x86_64                5.6.39-2.el7                mysql56-community
mysql-community-client.i686                 5.6.39-2.el7                mysql56-community
mysql-community-client.x86_64               5.6.39-2.el7                mysql56-community
mysql-community-common.i686                 5.6.39-2.el7                mysql56-community
mysql-community-common.x86_64               5.6.39-2.el7                mysql56-community
mysql-community-devel.i686                  5.6.39-2.el7                mysql56-community
mysql-community-devel.x86_64                5.6.39-2.el7                mysql56-community
mysql-community-embedded.i686               5.6.39-2.el7                mysql56-community
mysql-community-embedded.x86_64             5.6.39-2.el7                mysql56-community
mysql-community-embedded-devel.i686         5.6.39-2.el7                mysql56-community
mysql-community-embedded-devel.x86_64       5.6.39-2.el7                mysql56-community
mysql-community-libs.i686                   5.6.39-2.el7                mysql56-community
mysql-community-libs.x86_64                 5.6.39-2.el7                mysql56-community
mysql-community-server.x86_64               5.6.39-2.el7                mysql56-community
mysql-community-test.x86_64                 5.6.39-2.el7                mysql56-community
mysql-connector-java.noarch                 1:5.1.17-6.el6              base    
mysql-connector-odbc.x86_64                 5.3.9-1.el7                 mysql-connectors-community
mysql-connector-odbc-debuginfo.x86_64       5.3.9-1.el7                 mysql-connectors-community
mysql-connector-odbc-setup.x86_64           5.3.9-1.el7                 mysql-connectors-community
mysql-connector-python.noarch               2.0.4-1.el7                 mysql-connectors-community
mysql-connector-python.x86_64               2.1.7-1.el7                 mysql-connectors-community
mysql-connector-python-cext.x86_64          2.1.7-1.el7                 mysql-connectors-community
mysql-connector-python-debuginfo.x86_64     2.1.7-1.el7                 mysql-connectors-community
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-libs.x86_64                           5.1.73-8.el6_8              base    
mysql-ref-manual-5.6-en-html-chapter.noarch 1-20171211                  mysql56-community
mysql-ref-manual-5.6-en-pdf.noarch          1-20171211                  mysql56-community
mysql-router.x86_64                         2.1.4-1.el7                 mysql-tools-community
mysql-router-debuginfo.x86_64               2.1.4-1.el7                 mysql-tools-community
mysql-server.x86_64                         5.1.73-8.el6_8              base    
mysql-shell.x86_64                          1.0.11-1.el7                mysql-tools-community
mysql-shell-debuginfo.x86_64                1.0.11-1.el7                mysql-tools-community
mysql-test.x86_64                           5.1.73-8.el6_8              base    
mysql-utilities.noarch                      1.6.5-1.el7                 mysql-tools-community
mysql-utilities-extra.noarch                1.5.6-1.el7                 mysql-tools-community
mysql-workbench-community.x86_64            6.3.10-1.el7                mysql-tools-community
mysql-workbench-community-debuginfo.x86_64  6.3.10-1.el7                mysql-tools-community
pcp-pmda-mysql.x86_64                       3.10.9-9.el6                base    
php-mysql.x86_64                            5.3.3-49.el6                base    
qt-mysql.i686                               1:4.6.2-28.el6_5            base    
qt-mysql.x86_64                             1:4.6.2-28.el6_5            base    
rsyslog-mysql.x86_64                        5.8.10-10.el6_6             base    
rsyslog7-mysql.x86_64                       7.4.10-7.el6                base   
2.安装
[root@node0 opt]#yum install -y mysql-server mysql mysql-deve
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.cn99.com
 * updates: mirrors.cn99.com
包 yum-3.2.29-81.el6.centos.noarch 已安装并且是最新版本
No package install available.
No package mysql-deve available.
解决依赖关系
--> 执行事务检查
---> Package mysql.x86_64 0:5.1.73-8.el6_8 will be 安装
--> 处理依赖关系 mysql-libs = 5.1.73-8.el6_8,它被软件包 mysql-5.1.73-8.el6_8.x86_64 需要
--> 处理依赖关系 libmysqlclient_r.so.16(libmysqlclient_16)(64bit),它被软件包 mysql-5.1.73-8.el6_8.x86_64 需要
--> 处理依赖关系 libmysqlclient.so.16(libmysqlclient_16)(64bit),它被软件包 mysql-5.1.73-8.el6_8.x86_64 需要
--> 处理依赖关系 libmysqlclient_r.so.16()(64bit),它被软件包 mysql-5.1.73-8.el6_8.x86_64 需要
--> 处理依赖关系 libmysqlclient.so.16()(64bit),它被软件包 mysql-5.1.73-8.el6_8.x86_64 需要
---> Package mysql-server.x86_64 0:5.1.73-8.el6_8 will be 安装
--> 处理依赖关系 perl-DBI,它被软件包 mysql-server-5.1.73-8.el6_8.x86_64 需要
--> 处理依赖关系 perl-DBD-MySQL,它被软件包 mysql-server-5.1.73-8.el6_8.x86_64 需要
--> 处理依赖关系 perl(DBI),它被软件包 mysql-server-5.1.73-8.el6_8.x86_64 需要
--> 执行事务检查
---> Package mysql-libs.x86_64 0:5.1.73-8.el6_8 will be 安装
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be 安装
---> Package perl-DBI.x86_64 0:1.609-4.el6 will be 安装
--> 完成依赖关系计算


依赖关系解决


==============================================================================================================================================================================================================================================================================
 软件包                                                                架构                                                          版本                                                                   仓库                                                         大小
==============================================================================================================================================================================================================================================================================
正在安装:
 mysql                                                                 x86_64                                                        5.1.73-8.el6_8                                                         base                                                        895 k
 mysql-server                                                          x86_64                                                        5.1.73-8.el6_8                                                         base                                                        8.6 M
为依赖而安装:
 mysql-libs                                                            x86_64                                                        5.1.73-8.el6_8                                                         base                                                        1.2 M
 perl-DBD-MySQL                                                        x86_64                                                        4.013-3.el6                                                            base                                                        134 k
 perl-DBI                                                              x86_64                                                        1.609-4.el6                                                            base                                                        705 k


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


总下载量:12 M
Installed size: 33 M
下载软件包:
(1/5): mysql-5.1.73-8.el6_8.x86_64.rpm                                                                                                                                                                                                                 | 895 kB     00:00     
(2/5): mysql-libs-5.1.73-8.el6_8.x86_64.rpm                                                                                                                                                                                                            | 1.2 MB     00:01     
(3/5): mysql-server-5.1.73-8.el6_8.x86_64.rpm                                                                                                                                                                                                          | 8.6 MB     00:11     
(4/5): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm                                                                                                                                                                                                           | 134 kB     00:00     
(5/5): perl-DBI-1.609-4.el6.x86_64.rpm                                                                                                                                                                                                                 | 705 kB     00:00     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                                                                                                          812 kB/s |  12 MB     00:14     
运行 rpm_check_debug 
执行事务测试
事务测试成功
执行事务
Warning: RPMDB altered outside of yum.
** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.6.6-8.el6.x86_64 has missing requires of libmysqlclient.so.16()(64bit)
2:postfix-2.6.6-8.el6.x86_64 has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit)
  正在安装   : mysql-libs-5.1.73-8.el6_8.x86_64                                                                                                                                                                                                                           1/5 
  正在安装   : perl-DBI-1.609-4.el6.x86_64                                                                                                                                                                                                                                2/5 
  正在安装   : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                                                                                                                                                          3/5 
  正在安装   : mysql-5.1.73-8.el6_8.x86_64                                                                                                                                                                                                                                4/5 
  正在安装   : mysql-server-5.1.73-8.el6_8.x86_64                                                                                                                                                                                                                         5/5 
  Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                                                                                                                                                          1/5 
  Verifying  : perl-DBI-1.609-4.el6.x86_64                                                                                                                                                                                                                                2/5 
  Verifying  : mysql-server-5.1.73-8.el6_8.x86_64                                                                                                                                                                                                                         3/5 
  Verifying  : mysql-5.1.73-8.el6_8.x86_64                                                                                                                                                                                                                                4/5 
  Verifying  : mysql-libs-5.1.73-8.el6_8.x86_64                                                                                                                                                                                                                           5/5 


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


作为依赖被安装:
  mysql-libs.x86_64 0:5.1.73-8.el6_8                                                         perl-DBD-MySQL.x86_64 0:4.013-3.el6                                                         perl-DBI.x86_64 0:1.609-4.el6                                                        


完毕!
[root@node0 opt]#                                                  
查看版本号:
root@node0 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: 2018年01月15日 星期一 06时23分27秒      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@node0 opt]#  find / -name mysql
/usr/lib64/mysql
/usr/lib64/perl5/auto/DBD/mysql
/usr/lib64/perl5/DBD/mysql
/usr/bin/mysql
/usr/share/mysql
/var/lib/mysql

 启动mysql:

[root@node0 opt]# service mysqld start
初始化 MySQL 数据库: 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 node0 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:                                          [确定]

设置开机启动:

[root@node0 opt]# chkconfig --list | grep mysql
mysqld         	0:关闭	1:关闭	2:关闭	3:关闭	4:关闭	5:关闭	6:关闭
[root@node0 opt]# chkconfig mysqld on
[root@node0 opt]# chkconfig --list | grep mysql
mysqld         	0:关闭	1:关闭	2:启用	3:启用	4:启用	5:启用	6:关闭
[root@node0 opt]# 

设置root账号密码:

[root@node0 opt]# mysqladmin -u root password 'root'
[root@node0 opt]# 

进入root账号:

[root@node0 opt]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 Source distribution


Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql>
安装完毕!
 
 
 
 
 

                
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值