• Centos7安装MySQL


    环境说明:centos7.5,mysql5.7

    #卸载系统自带的Mariadb

    # rpm -qa | grep mariadb

    # rpm -e --nodeps mariadb文件名 

     

    #删除etc目录下的my.cnf文件

    # rm -rf /etc/my.cnf

     

    #安装mysql依赖库文件libaio

    # yum -y install libaio*

    #下载压缩包到/usr/local,解压在当前目录并重命名为mysql5.7

    # cd /usr/local

    # yum install wget

    # wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

    # tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

    # mv mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz mysql5.7

     

    #添加组和用户

    # groupadd mysql

    # useradd -g mysql mysql

     

    #创建配置文件

    # vi /etc/my.cnf

    [mysqld]

    user=mysql

    port=3306

    basedir=/usr/local/mysql5.7/

    datadir=/usr/local/mysql5.7/data/

    character-set-server=utf8

    collation-server=utf8_bin

     

    #创建数据目录并初始化

    # mkdir -p /usr/local/mysql5.7/data/

    # chown -R mysql:mysql /usr/local/mysql5.7/data/

    # /usr/local/mysql5.7/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql5.7 --datadir=/usr/local/mysql5.7/data/&

     

    A temporary password is generated for root@localhost:这里就是数据库的初始密码

    #开启mysql服务,用初始密码登录数据,并修改初始密码

    # /usr/local/mysql5.7/support-files/mysql.server start

    # /usr/local/mysql5.7/bin/mysql -u root -p

    > set password=password('新密码');

    #设置环境变量

    # vi /etc/profile

    ## FOR MYSQL ##

    export PATH=/usr/local/mysql5.7/bin:$PATH

    # source /etc/profile

     

    #设置开机自启动

    # cp /usr/local/mysql5.7/support-files/mysql.server /etc/init.d/mysql

    # chmod +x /etc/init.d/mysql

    # chkconfig --add mysql

    # chkconfig --level 35 mysql on

     

    #数据库设置允许远程主机访问

    > use mysql;

    > update user set host = '%' where user = 'root';

    #重启数据库服务

    # service mysql stop

    # service mysql start

    #防火墙放开mysql数据库3306端口

    # firewall-cmd --zone=public --add-port=3306/tcp --permanent

    # firewall-cmd --reload

    好了,大功告成!

  • 相关阅读:
    2019-2020-1 20175315 20175322 20175334 实验五 通讯协议设计
    bfs思路总结
    蓝桥杯-带分数
    Passive WiFi Tracking
    openWRT刷机设置
    研究生若干事
    Dijkstra算法和Floyed算法
    最小生成树prim算法
    无穷大量0x3f3f3f3f
    杭电OJ题目分类
  • 原文地址:https://www.cnblogs.com/heqiuyong/p/9735158.html
Copyright © 2020-2023  润新知