zoukankan      html  css  js  c++  java
  • Centos安装MYSQL

    官网下载安装mysql-server

    # wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

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

    # yum install mysql-community-server

    安装成功后重启mysql服务。

    # service mysqld restart

    初次安装mysql,root账户没有密码。

    clip_image001

    [root@yl-web yl]# mysql -u root

    Welcome to the MySQL monitor. Commands end with ; or g.

    ….

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

    mysql> show databases;

    +--------------------+

    | Database |

    +--------------------+

    | information_schema |

    | mysql |

    | performance_schema |

    | test |

    +--------------------+

    4 rows in set (0.01 sec)

    mysql>

    设置密码

    mysql> set password for 'root'@'localhost' =password('password');

    Query OK, 0 rows affected (0.00 sec)

    mysql>

    配置mysql

    1、编码

    mysql配置文件为/etc/my.cnf

    最后加上编码配置

    [mysql]

    default-character-set =utf8

    这里的字符编码必须和/usr/share/mysql/charsets/Index.xml中一致。

    clip_image002

    2、远程连接设置

    把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。

    mysql> grant all privileges on *.* to root@'%'identified by 'password';

    如果是新用户而不是root,则要先新建用户

    mysql>create user 'username'@'%' identified by 'password';

    此时就可以进行远程连接了。

    3、防火墙设置

    开放防火墙:

    service firewalld stop 或者 systemctl stop firewalld.service

    然后安装iptables-services:

    yum install iptables-services

    编辑配置文件:

    vim /etc/sysconfig/iptables

    在commit之前加一行

    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306-j ACCEPT

    重启服务

    service iptables restart

  • 相关阅读:
    OC面向对象—封装
    设计模式之类关系
    理性:中国别一厢情愿救俄罗斯(转)
    Mockito--完整功能介绍(转)
    从陌陌上市看BAT的移动保卫战(转)
    This exception may occur if matchers are combined with raw values
    RepositoryClassLoader.java
    搭建你的持续集成server
    mysql中怎样查看和删除唯一索引
    Android中Context具体解释 ---- 你所不知道的Context
  • 原文地址:https://www.cnblogs.com/madyina/p/6536468.html
Copyright © 2011-2022 走看看