CentOS 7.4 安装 MySQL 8.0.12 解压版

前期准备
            1.下载Mysql解压版tar文件[mysql-8.0.18-linux-glibc2.12-x86_64.tar],
            2.解压mysql安装文件
                tar -xvf mysql-8.0.18-linux-glibc2.12-x86_64.tar
                tar -xvf mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz
            3.复制解压后的mysql到软件目录:
                mv /mysql-8.0.18-linux-glibc2.12-x86_64 /usr/local/service/mysql
            4.添加系统mysql组和mysql用户:
                groupadd mysql
                useradd -r -g mysql -s /bin/false mysql
        安装:
            1.进入目录/usr/local/service/mysql
                cd /usr/local/service/mysql
            2.用户赋权:
                chown -R mysql:mysql ./
            3.修改my.conf
                vi /etc/my.conf
                    [client]
                    port=3306 # 设置mysql客户端连接服务端时默认使用的端口
                    default-character-set=utf8
                    socket=/data/soft/mysql-8.0.12-el7-x86_64/data/mysql.sock
                    [mysqld]
                    basedir=/data/soft/mysql-8.0.12-el7-x86_64 # 设置mysql的安装目录
                    datadir=/data/soft/mysql-8.0.12-el7-x86_64/data
                    socket=/data/soft/mysql-8.0.12-el7-x86_64/data/mysql.sock
                    # Disabling symbolic-links is recommended to prevent assorted security risks
                    symbolic-links=0
                    # Settings user and group are ignored when systemd is used.
                    # If you need to run mysqld under a different user or group,
                    # customize your systemd unit file for mariadb according to the
                    # instructions in http://fedoraproject.org/wiki/Systemd
                    [mysqld_safe]
                    log-error=/data/log/mysql-log/error.log
                    pid-file=/data/soft/mysql-8.0.12-el7-x86_64/data/mysql.pid
                    #
                    # include all files from the config directory
                    #
                    !includedir /etc/my.cnf.d
            4.保存退出
                ESC -> :wq(保存退出)
            5.日志文件授权:
                vim /data/log/mysql-log/error.log
                chown mysql:mysql /data/log/mysql-log/error.log
            6.初始化数据库
                ./bin/mysqld --initialize --user=mysql
            7.启动/关闭数据库
                service mysql start/stop
            8.添加mysql命令
                vim /etc/profile
                    export MYSQL_HOME=/usr/local/server/mysql8.0.18
                    export PATH=$PATH:$MYSQL_HOME/bin
        使用:
            1.进入数据库[密码为初始化时生成]
                mysql -u root -p 
            2.修改root密码
                ALTER user 'root'@'localhost' [with mysql_native_password] identified by 'newpassword';
                备注:[with mysql_native_password-用于native登录]
            3.flush privileges;//刷新权限
            4.quit;//退出重新登录
            5.重新进入数据库
                mysql -u root -p 
            6.远程连接
                update mysql.user set host = '%' where user = 'root' limit 1;
            7.flush privileges;//刷新权限
    启动:service mysql start

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值