zoukankan      html  css  js  c++  java
  • linux CentOS6.5 yum安装mysql 5.6(转载&删改)

    按:下面文章经过我一路测试没有问题,是篇好文,在此感谢作者 别踩我袈裟  。另因原文有些啰嗦,我自己有所删改,并尾后增加了一大段。

    出处:https://www.cnblogs.com/renjidong/p/7047396.html

    1.先检测系统是否自带安装mysql

    # yum list installed | grep mysql

    2.如果发现有系统自带mysql,删除之

    # yum -y remove mysql-libs.x86_64


    3.从网络获取mysql5.6(79M),解释一下,这个rpm还不是mysql的安装文件,只是两个yum源文件

    # wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm


    4.接着执行这句,执行后在/etc/yum.repos.d/ 这个目录下多出mysql-community-source.repo和mysql-community.repo

    # rpm -ivh mysql-community-release-el6-5.noarch.rpm


    5.这个时候,可以用yum repolist mysql这个命令查看一下是否已经有mysql可安装文件

    #yum repolist all | grep mysql


    6.安装mysql 服务器命令(一路yes):

    # yum install mysql-community-server


    7.安装成功后,启动mysql

    # service mysqld start


    8.由于mysql刚刚安装完的时候,mysql的root用户的密码默认是空的,所以我们需要及时用mysql的root用户登录(第一次回车键,不用输入密码),并修改密码

    # mysql -u root
    mysql> use mysql;
    mysql> update user set password=PASSWORD('123456') where User='root';
    mysql> flush privileges;


    9.查看mysql是否自启动,并且设置开启自启动命令

    # chkconfig --list | grep mysqld
    # chkconfig mysqld on


    10.mysql安全设置(系统会一路问你几个问题,基本上一路yes):

    # mysql_secure_installation

    以下为我个人添加的内容:

    进入mysql数据库管理控制台,让远程可以访问。
    #mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 4
    Server version: 5.0.67 Source distribution

    Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

    mysql> grant all privileges on *.* to root@'%' identified by "root";
    Query OK, 0 rows affected (0.00 sec)

    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

    mysql> quit
    Bye

    上面的步骤是进行授权

    然后重启mysqld服务
    service mysqld restart
    Stopping MySQL:                                            [  OK  ]
    Starting MySQL:                                            [  OK  ]

    再次进入mysql管理控制台(修改密码这一步不可或缺,否则容易出现“access denied for user root @localhost”错误
    mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.0.67 Source distribution

    Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

    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> update user set password=password('12345678') where user='root';
    Query OK, 5 rows affected (0.00 sec)
    Rows matched: 5  Changed: 5  Warnings: 0

    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

    mysql> quit
    Bye

    以上步骤是修改root用户的密码

    之后开启防火墙的3306端口
    vi /etc/sysconfig/iptables

    以下是/etc/sysconfig/iptables的内容,其中蓝色一行是新加的。这一行可以由上一行复制得到,方法是在22哪行按下yy进行行复制,然后按p进行粘贴,然后点insert键进入编辑模式,修改22为3306,然后点esc,输入wq保存退出。
    # Firewall configuration written by system-config-firewall
    # Manual customization of this file is not recommended.
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    -A INPUT -p icmp -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -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
    -A INPUT -j REJECT --reject-with icmp-host-prohibited
    -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    COMMIT

    防火墙重启
    service iptables restart
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
    iptables: Unloading modules:                               [  OK  ]
    iptables: Applying firewall rules:                         [  OK  ]

    之后就可以在终端上敲#ifconfig,找出虚拟机对应的ip地址,比如说是192.168.0.100,然后就可以用mysql-front或程序连接数据库了。

     2018年3月25日14点41分

  • 相关阅读:
    Cleve Moler MATLAB 创始人金秋10月中国大学校园行
    [原]ASP.NET中使用JQUERYEASYUI后,解决ClientScript.RegisterStartupScript 所注册脚本执行两次
    [原]ASP.NET中使用后端代码注册脚本 生成JQUERYEASYUI 的界面错位
    [原]jqueryeasyui 关闭tab如何自动切换到前一个tab
    [原创]C# 实例Oracle 备份,带进度提示
    停止Oracle 服务开机自动重启
    最新县及县以上行政区划代码(截止2009年12月31日)
    单元测试学习:无返回值,触发委托
    [笔记]GetRequestStream()超时问题(出现假死,卡住)
    asp.net 页面 css中图片不存在引发的异常
  • 原文地址:https://www.cnblogs.com/heyang78/p/8644429.html
Copyright © 2011-2022 走看看