美文网首页
Linux安装Mysql

Linux安装Mysql

作者: 年少时难免轻狂Ho | 来源:发表于2018-12-26 14:46 被阅读0次

    修改配置文件

    vi ~/.my.cnf
    
    # 在~/.my.cnf文件中添加下列信息
    [client]
    port = 3306
    socket = /home/ocetl/mysql-5.7.18/mysql.sock
    [mysqld]
    user = ocetl
    basedir = /home/ocetl/mysql-5.7.18
    datadir = /home/ocetl/mysql-5.7.18/data
    port = 3306
    server-id = 1
    socket = /home/ocetl/mysql-5.7.18/mysql.sock
    character-set-server = utf8
    log-error = /home/ocetl/mysql-5.7.18/logs/error.log
    pid-file = /home/ocetl/mysql-5.7.18/logs/mysql.pid
    [mysqldump]
    quick
    max_allowed_packet = 16M
    [myisamchk]
    key_buffer_size = 8M
    sort_buffer_size = 8M
    read_buffer = 4M
    write_buffer = 4M
    

    修改环境变量

    export MY_BASEDIR_VERSION=~/mysql-5.7.18/
    export PATH=${MY_BASEDIR_VERSION}/bin:$PATH
    

    创建目录

    mkdir -p ~/mysql-5.7.18/data
    mkdir -p ~/mysql-5.7.18/logs
    

    初始化

    mysqld --initialize --user=ocetl
    

    启动与停止

    # 启动
    mysqld &
    # 停止
    mysqladmin -uhive -phive shutdown
    

    修改初始密码

    # root初始密码获取
    grep "password" ~/mysql-5.7.18/logs/error.log
    # 使用上述密码登录
    mysql -uroot -p
    alter user root@localhost identified by 'Asia2017_';
    flush privileges;
    
    

    相关文章

      网友评论

          本文标题:Linux安装Mysql

          本文链接:https://www.haomeiwen.com/subject/ckuhlqtx.html