zoukankan      html  css  js  c++  java
  • Linux下的mysql5.7的安装

    一、下载MYSQL
    在官方网站下载MySQL安装包,下载地址: https://www.mysql.com/downloads/
    安装MYSQL

    1. 解压MySQL安装包
    tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz 
    mv mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local/mysql
    
    1. 添加系统用户和用户组
     groupadd mysql
     useradd -r -g mysql mysql
    
    1. 创建MySQL数据目录
    mkdir /usr/local/mysql/data
    
    1. 修改MySQL目录权限
    chown -R mysql:mysql /usr/local/mysql
    
    1. 初始化数据库
     cd /usr/local/mysql
     ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
    
    1. 修改MySQL目录权限
     chown -R root:root ./
     chown -R mysql:mysql data
    
    1. 添加启动服务
    cp support-files/mysql.server /etc/init.d/mysql
    
    1. 修改MySQL配置文件
     vim /etc/my.cnf
     [mysqld]
     basedir=/usr/local/mysql
     datadir=/usr/local/mysql/data
     socket=/tmp/mysql.sock
     user=mysql
     port=3306
     character-set-server=utf8
     symbolic-links=0
     ​
     [mysqld_safe]
     log-error=/var/log/mysqld.log
     pid-file=/var/run/mysqld/mysqld.pid
     ​
     !includedir /etc/my.cnf.d
    

    三、配置MySQL账号密码以及远程连接

    1. 修改my.cnf配置
     [mysqld]
     datadir=/usr/local/mysql/data
     basedir=/usr/local/mysql
     socket=/tmp/mysql.sock
     user=mysql
     port=3306
     character-set-server=utf8
     # 跳过密码验证
     skip-grant-tables 
     symbolic-links=0
     ​
     [mysqld_safe]
     log-error=/var/log/mysqld.log
     pid-file=/var/run/mysqld/mysqld.pid
     ​
     !includedir /etc/my.cnf.d
    
    1. 重启MySQL服务
    service mysql restart
    
    1. 设置用户登陆密码
     mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
     mysql> FLUSH PRIVILEGES;
    
    1. 设置MySQL远程访问
     mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
     mysql> FLUSH PRIVILEGES;
    
  • 相关阅读:
    《Java面向对象编程》
    大学计算机基础考试系统(CS)
    企业物资管理系统
    IP.21出现的错误
    假如你的年龄超过了23···
    如何经营婚姻
    一张舞女图测试你的左右脑切换能力【我看到左右都转呢~】
    无法加载DLL(oci.dll)
    mongodb安装信息及有关命令
    loaded the "controller" nib but the view outlet was not set.问题解决
  • 原文地址:https://www.cnblogs.com/cainiaoxiaoxie/p/12622265.html
Copyright © 2011-2022 走看看