zoukankan      html  css  js  c++  java
  • linux上安装mysql

    CentOS7上安装MySQL5.7.17

    http://www.cnblogs.com/starof/p/4680083.html
    http://www.centoscn.com/mysql/2016/0315/6844.html
    CentOS 7 版本将MySQL数据库软件从默认的程序列表中移除,用mariadb代替了

    # 下载mysql的Yum源   https://dev.mysql.com/downloads/  -->  MySQL Yum Repository
    curl -o ~/mysql/mysql57-community-release-el7-9.noarch.rpm https://repo.mysql.com/mysql57-community-release-el7-9.noarch.rpm
    # 将mysql的yum源添加到系统中
    yum localinstall ~/mysql/mysql57-community-release-el7-9.noarch.rpm
    # 验证下是否添加成功
    yum repolist enabled | grep "mysql.*-community.*"
    
    # 查看 MySQL 版本
    yum repolist all | grep mysql
    # 启用或禁用某版本
    yum-config-manager --disable mysql56-community
    yum-config-manager --enable mysql57-community-dmr
    # 查看当前的启用的 MySQL 版本
    yum repolist enabled | grep mysql
    
    # 通过 Yum 来安装 MySQL
    yum -y install mysql-community-server
    # 查看mysql安装目录
    whereis mysql
    
    # 启动 MySQL Server
    systemctl start mysqld
    # 查看 MySQL Server 状态
    systemctl status mysqld
    # 关闭 MySQL Server
    systemctl stop mysqld
    
    # 重置root密码: http://blog.csdn.net/praying2/article/details/54312776
    # 在/etc/my.cnf最后添加一行skip-grant-tables
    echo "skip-grant-tables" >> /etc/my.cnf
    systemctl restart mysqld
    mysql
    use mysql;
    # update user set password=PASSWORD('root') where User='root'; #5.7.5 之前
    #5.7.6以上
    update user set authentication_string=PASSWORD('root') where User='root';
    exit
    # 删除/etc/my.cnf最后一行的skip-grant-tables
    sed -i '$d' /etc/my.cnf
    systemctl restart mysqld
    # 使用root带密码登录
    mysql -u root  -p
    # 修改密码:http://www.cnblogs.com/ivictor/p/5142809.html
    # 显示validate_password插件, MySQL5.7默认安装
    SHOW VARIABLES LIKE 'validate_password%';
    set global validate_password_policy=0;
    set global validate_password_mixed_case_count=0;
    set global validate_password_number_count=0;
    set global validate_password_special_char_count=0;
    set global validate_password_length=0;
    # 经过上面的设置0,此时,才可以将配置为空的
    SET PASSWORD = PASSWORD('');
    
    # 配置允许远程连接
    mysql
    use mysql;
    update user set host = '%' where user = 'root';
    flush privileges;
    exit
    # 开放默认端口号 3306
    firewall-cmd --permanent --zone=public --add-port=3306/tcp
    firewall-cmd --permanent --zone=public --add-port=3306/udp
    firewall-cmd --reload
    
    # MySQL 安全设置   不需要
    # mysql_secure_installation
    
    # 设置字符集
    mysql
    # character_set_database
    SHOW VARIABLES LIKE 'character%';
    exit
    vi /etc/my.cnf
    # [mysqld]   
    # character_set_server = utf8
    # [mysql]
    # default-character-set = utf8
    
  • 相关阅读:
    面向对象(二)
    关于CURL的初步认识
    Mysql数据库进阶之(分表分库,主从分离)
    解决mysql:Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
    git的那些事
    今天我们来聊聊svn的使用
    基于CentOS6.8版本配置真实域名的方法
    WDCP v3 安装
    Ubuntu无法ssh远程连接问题 (转)
    Linux运维入门到高级全套系列PDF
  • 原文地址:https://www.cnblogs.com/chencye/p/6642602.html
Copyright © 2011-2022 走看看