欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

centos 6.5下 mysql-community-server. 5.7.18-1.el6安装

程序员文章站 2023-02-17 14:40:14
使用下面的命令检查是否安装有mysql server [root@localhost etc]# rpm -qa | grep mysql // 这个命令就会查看...

使用下面的命令检查是否安装有mysql server

[root@localhost etc]# rpm -qa | grep mysql // 这个命令就会查看该操作系统上是否已经安装了mysql数据库

   有的话,我们就通过 rpm -e 命令 或者 rpm -e --nodeps 命令来卸载掉

[root@localhost ~]# rpm -e mysql  // 普通删除模式
[root@localhost ~]# rpm -e --nodeps mysql  // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除

   在删除完以后我们可以通过 rpm -qa | grep mysql 命令来查看mysql是否已经卸载成功!!

官网yum repository 下载安装包

[root@localhost ~]# wget http://dev.mysql.com/get/mysql57-community-release-el6-10.noarch.rpm
 --2017-04-24 18:53:49-- http://dev.mysql.com/get/mysql57-community-release-el6-10.noarch.rpm
resolving dev.mysql.com... 137.254.60.11
connecting to dev.mysql.com|137.254.60.11|:80... connected.
http request sent, awaiting response... 301 moved permanently
location: https://dev.mysql.com/get/mysql57-community-release-el6-10.noarch.rpm [following]
--2017-04-24 18:53:49-- https://dev.mysql.com/get/mysql57-community-release-el6-10.noarch.rpm
connecting to dev.mysql.com|137.254.60.11|:443... connected.
error: certificate common name “www.mysql.com” doesn't match requested host name “dev.mysql.com”.
to connect to dev.mysql.com insecurely, use ‘--no-check-certificate'

本地安装下载下来的rpm包

[root@localhost ~]# yum localinstall mysql57-community-release-el6-10.noarch.rpm
loaded plugins: fastestmirror, refresh-packagekit, security
setting up local package process
examining mysql57-community-release-el6-10.noarch.rpm: mysql57-community-release-el6-10.noarch
marking mysql57-community-release-el6-10.noarch.rpm to be installed
loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.cn99.com
 * updates: mirrors.cn99.com
resolving dependencies
--> running transaction check
---> package mysql57-community-release.noarch 0:el6-10 will be installed
--> finished dependency resolution
dependencies resolved
===============================================================================================================================================================================================
 package                      arch              version              repository                             size
===============================================================================================================================================================================================
installing:
 mysql57-community-release             noarch             el6-10               /mysql57-community-release-el6-10.noarch              30 k
transaction summary
===============================================================================================================================================================================================
install    1 package(s)
total size: 30 k
installed size: 30 k
is this ok [y/n]: y
downloading packages:
running rpm_check_debug
running transaction test
transaction test succeeded
running transaction
 installing : mysql57-community-release-el6-10.noarch                                   1/1
 verifying : mysql57-community-release-el6-10.noarch                                     1/1
installed:
 mysql57-community-release.noarch 0:el6-10                          
complete!

  查看可用的安装包 

[root@localhost ~]# yum repolist enabled|grep mysql
mysql-connectors-community      mysql connectors community       33
mysql-tools-community        mysql tools community          47
mysql57-community          mysql 5.7 community server       183

安装前装gcc所有包,防止报错[errno -1]  package does not match intended download

[root@localhost yum.repos.d]# yum install gcc* 

安装mysql

[root@localhost yum.repos.d]# yum install -y mysql-community-server 
loaded plugins: fastestmirror, refresh-packagekit, security
loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.cn99.com
 * updates: mirrors.cn99.com
setting up install process
resolving dependencies
--> running transaction check
---> package mysql-community-server.x86_64 0:5.7.18-1.el6 will be installed
--> processing dependency: mysql-community-common(x86-64) = 5.7.18-1.el6 for package: mysql-community-server-5.7.18-1.el6.x86_64
--> processing dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.18-1.el6.x86_64
--> running transaction check
---> package mysql-community-client.x86_64 0:5.7.18-1.el6 will be installed
--> processing dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.18-1.el6.x86_64
---> package mysql-community-common.x86_64 0:5.7.18-1.el6 will be installed
--> running transaction check
---> package mysql-community-libs.x86_64 0:5.7.18-1.el6 will be obsoleting
---> package mysql-libs.x86_64 0:5.1.71-1.el6 will be obsoleted
--> processing dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-2.2.el6_1.x86_64
--> processing dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-2.2.el6_1.x86_64
--> running transaction check
---> package mysql-community-libs-compat.x86_64 0:5.7.18-1.el6 will be obsoleting
---> package postfix.x86_64 2:2.6.6-2.2.el6_1 will be updated
---> package postfix.x86_64 2:2.6.6-8.el6 will be an update
--> finished dependency resolution
dependencies resolved
=============================================================================================================================
 package                 arch        version           repository           size
=============================================================================================================================
installing:
 mysql-community-libs          x86_64       5.7.18-1.el6         mysql57-community       2.1 m
   replacing mysql-libs.x86_64 5.1.71-1.el6
 mysql-community-libs-compat       x86_64       5.7.18-1.el6         mysql57-community       1.6 m
   replacing mysql-libs.x86_64 5.1.71-1.el6
 mysql-community-server         x86_64       5.7.18-1.el6         mysql57-community       152 m
installing for dependencies:
 mysql-community-client         x86_64       5.7.18-1.el6         mysql57-community       23 m
 mysql-community-common         x86_64       5.7.18-1.el6         mysql57-community       328 k
updating for dependencies:
 postfix                 x86_64       2:2.6.6-8.el6        base             2.0 m
transaction summary
=============================================================================================================================
install    5 package(s)
upgrade    1 package(s)
total size: 180 m
total download size: 152 m
downloading packages:
mysql-community-server-5.7.18-1.el6.x86_64.rpm                            | 152 mb   01:41  
warning: rpmts_hdrfromfdno: header v3 dsa/sha1 signature, key id 5072e1f5: nokey
retrieving key from file:///etc/pki/rpm-gpg/rpm-gpg-key-mysql
importing gpg key 0x5072e1f5:
 userid : mysql release engineering <mysql-build@oss.oracle.com>
 package: mysql57-community-release-el6-10.noarch (@/mysql57-community-release-el6-10.noarch)
 from  : /etc/pki/rpm-gpg/rpm-gpg-key-mysql
running rpm_check_debug
running transaction test
transaction test succeeded
running transaction
 installing : mysql-community-common-5.7.18-1.el6.x86_64                                1/8
 installing : mysql-community-libs-5.7.18-1.el6.x86_64                                 2/8
 installing : mysql-community-libs-compat-5.7.18-1.el6.x86_64                              3/8
 installing : mysql-community-client-5.7.18-1.el6.x86_64                                4/8
 installing : mysql-community-server-5.7.18-1.el6.x86_64                                5/8
 updating  : 2:postfix-2.6.6-8.el6.x86_64                                       6/8
 cleanup  : 2:postfix-2.6.6-2.2.el6_1.x86_64                                     7/8
 erasing  : mysql-libs-5.1.71-1.el6.x86_64                                      8/8
 verifying : 2:postfix-2.6.6-8.el6.x86_64                                       1/8
 verifying : mysql-community-libs-compat-5.7.18-1.el6.x86_64                              2/8
 verifying : mysql-community-server-5.7.18-1.el6.x86_64                                3/8
 verifying : mysql-community-libs-5.7.18-1.el6.x86_64                                 4/8
 verifying : mysql-community-common-5.7.18-1.el6.x86_64                                5/8
 verifying : mysql-community-client-5.7.18-1.el6.x86_64                                6/8
 verifying : 2:postfix-2.6.6-2.2.el6_1.x86_64                                     7/8
 verifying : mysql-libs-5.1.71-1.el6.x86_64                                      8/8
installed:
 mysql-community-libs.x86_64 0:5.7.18-1.el6         mysql-community-libs-compat.x86_64 0:5.7.18-1.el6       
 mysql-community-server.x86_64 0:5.7.18-1.el6       
dependency installed:
 mysql-community-client.x86_64 0:5.7.18-1.el6         mysql-community-common.x86_64 0:5.7.18-1.el6        
dependency updated:
 postfix.x86_64 2:2.6.6-8.el6                                               
replaced:
 mysql-libs.x86_64 0:5.1.71-1.el6                        
complete!

启动mysql

[root@localhost yum.repos.d]# service mysqld start  
initializing mysql database:                [ ok ]
installing validate password plugin:            [ ok ]
starting mysqld: 

  进入mysql安全模式

[root@localhost yum.repos.d]# killall -term mysqld
[root@localhost yum.repos.d]# mysqld_safe --skip-grant-tables &
[1] 40422
[root@localhost yum.repos.d]# 2017-04-25t07:45:39.222061z mysqld_safe logging to '/var/log/mysqld.log'.
2017-04-25t07:45:39.246117z mysqld_safe starting mysqld daemon with databases from /var/lib/mysql
mysql -uroot -p
enter password:
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id is 3
server version: 5.7.18 mysql community server (gpl)
copyright (c) 2000, 2017, 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> use mysql
reading table information for completion of table and column names
you can turn off this feature to get a quicker startup with -a
database changed
mysql> select * from users;
error 1146 (42s02): table 'mysql.users' doesn't exist
mysql> select * from user;
mysql> update user set authentication_string=password('mysql') where user='root';
query ok, 1 row affected, 1 warning (0.00 sec)
rows matched: 1 changed: 1 warnings: 1
mysql> quit
bye
[2]+ exit 1         mysqld_safe --skip-grant-tables
  
[root@localhost yum.repos.d]# service mysqld start
starting mysqld:                      [ ok ]
[root@localhost yum.repos.d]# mysql -uroot -p
enter password:
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id is 5
server version: 5.7.18 mysql community server (gpl)
copyright (c) 2000, 2017, 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 -h主机地址 -u用户名 -p用户密码

1、例1:连接到本机上的mysql

   找到mysql的安装目录,一般可以直接键入命令mysql -uroot -p,回车后提示你输密码,如果刚安装好mysql,超级用户root是没有密码的,故直接回车即可进入到mysql中

了,mysql的提示符是:mysql>

2、连接到远程主机上的mysql

   假设远程主机的ip为:10.0.0.1,用户名为root,密码为123。则键入以下命令:

mysql -h10.0.0.1 -uroot -p123

  (注:u与root可以不用加空格,其它也一样)

配置防火墙

防火墙的3306端口默认没有开启,若要远程访问,需要开启这个端口

打开/etc/sysconfig/iptables

在“-a input –m state --state new –m tcp –p tcp –dport 22 –j accept”,下添加:

-a input -m state --state new -m tcp -p tcp --dport 3306 -j accept

然后保存,并关闭该文件,在终端内运行下面的命令,刷新防火墙配置:

service iptables restart ok,一切配置完毕,你可以访问你的mysql了~

注意:增加的开放3306端口的语句一定要在icmp-host-prohibited之前

mysql -uroot -p
enter password: 
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id is 3
server version: 5.7.18 mysql community server (gpl)

copyright (c) 2000, 2017, 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.

以上所述是小编给大家介绍的centos 6.5下 mysql-community-server. 5.7.18-1.el6安装,希望对大家有所帮助