CentOS-minimal 6.5 安装mysql

2 篇文章 0 订阅
2 篇文章 0 订阅

CentOS-minimal 6.5 安装mysql

之前写了一个在Ubuntu上使用离线包安装mysql的过程,相较于CentOS来说稍微麻烦点,因为mysql提供了rpm安装包。

在安装之前,我们先把所需的安装包下载下来,使用的版本还是5.5.45,与Ubuntu离线包的区别是,这里我们要下载三个安装包,下载链接如下:

http://cdn.mysql.com/archives/mysql-5.5/MySQL-server-5.5.45-1.linux2.6.x86_64.rpm

http://cdn.mysql.com/archives/mysql-5.5/MySQL-client-5.5.45-1.linux2.6.x86_64.rpm

http://cdn.mysql.com/archives/mysql-5.5/MySQL-devel-5.5.45-1.linux2.6.x86_64.rpm

这里还是建议使用迅雷下载,下载完成后待用。

  • 首先,我使用的CentOS是minimal6.5版本的,查看是否安装了mysql:
    [root@qiuxiao ~]# rpm -qa | grep mysql
    mysql-libs-5.1.71-1.el6.x86_64
  • 此版本默认安装了mysql-libs(其他版本我也看过了,安装的更多),先把它卸载掉,否则后面安装不了:
    [root@qiuxiao ~]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
  • 在安装之前先安装一个依赖包,mysql运行的时候会用到这个依赖包,否则运行不了:
    [root@qiuxiao ~]# yum install libaio
  • 安装mysql,安装顺序如下(别忘了先上传到CentOS上,我是上传到/usr/local/目录下),注意输出的信息,会用到的:
    [root@qiuxiao local]# rpm -ivh MySQL-server-5.5.45-1.linux2.6.x86_64.rpm
    warning: MySQL-server-5.5.45-1.linux2.6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Preparing...                ########################################### [100%]
       1:MySQL-server           ########################################### [100%]
    151020 19:14:16 [Note] /usr/sbin/mysqld (mysqld 5.5.45) starting as process 1240 ...
    151020 19:14:16 [Note] /usr/sbin/mysqld (mysqld 5.5.45) starting as process 1247 ...

    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 qiuxiao 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.

    Please report any problems at http://bugs.mysql.com/

    [root@qiuxiao local]# rpm -ivh MySQL-client-5.5.45-1.linux2.6.x86_64.rpm
    warning: MySQL-client-5.5.45-1.linux2.6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Preparing...                ########################################### [100%]
       1:MySQL-client           ########################################### [100%]

    [root@qiuxiao local]# rpm -ivh MySQL-devel-5.5.45-1.linux2.6.x86_64.rpm
    warning: MySQL-devel-5.5.45-1.linux2.6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Preparing...                ########################################### [100%]
       1:MySQL-devel            ########################################### [100%]
  • 启动mysql服务:
    [root@qiuxiao local]# service mysql start
    Starting MySQL.. SUCCESS!
  • 修改root密码:
    [root@qiuxiao local]# /usr/bin/mysqladmin -u root password 'new password'
  • 登录mysql:

    [root@qiuxiao local]# mysql -u root -p
    Enter password: 
  • 设置字符集
    1)查询字符集:

    mysql> show variables like'character%';

    查询字符集

    2)修改字符集:

    mysql> SET character_set_database = utf8;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> SET character_set_server = utf8;
    Query OK, 0 rows affected (0.00 sec)
  • 设置root用户可以远程连接(以下两种任选其一)
    1)从所有主机:

    mysql> grant all privileges on *.* to root@"%" identified by"root用户的密码"with grant option;
    Query OK, 0 rows affected (0.00 sec)

    2)从指定主机:

    mysql> grant all privileges on *.* to root@"192.168.11.205" identified by"root用户的密码"with grant option; flush privileges;
    Query OK, 0 rows affected (0.00 sec)
  • 重启mysql服务

    [root@qiuxiao ~]# service mysql restart
    Shutting down MySQL... SUCCESS! 
    Starting MySQL.. SUCCESS!
  • 防火墙开放mysql端口3306
    1)开放3306端口:

    [root@qiuxiao ~]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT

    2)保存:

    [root@qiuxiao ~]# /etc/rc.d/init.d/iptables save
    iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

    3)重启防火墙:

    [root@qiuxiao ~]# /etc/init.d/iptables restart
    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Unloading modules:                               [  OK  ]
    iptables: Applying firewall rules:                         [  OK  ]
  • Navicat连接mysql
    Nacicat连接mysql

连接成功

由图可知,连接成功!
此处有掌声

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值