centos7安装mysql

  1. 准备两台centos主机(这里两台主机IP为192.168.2.11和192.168.2.12)
  2. 到mysql官网下载mysql5.7 bundle
    mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar
  3. 解压mysql5.7
    包含10个文件
    mysql-community-client-5.7.37-1.el7.x86_64.rpm
    mysql-community-common-5.7.37-1.el7.x86_64.rpm
    mysql-community-devel-5.7.37-1.el7.x86_64.rpm
    mysql-community-embedded-5.7.37-1.el7.x86_64.rpm
    mysql-community-embedded-compat-5.7.37-1.el7.x86_64.rpm
    mysql-community-embedded-devel-5.7.37-1.el7.x86_64.rpm
    mysql-community-libs-5.7.37-1.el7.x86_64.rpm
    mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm
    mysql-community-server-5.7.37-1.el7.x86_64.rpm
    mysql-community-test-5.7.37-1.el7.x86_64.rpm
  4. 删除mariadb
    rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
  5. 安装
    rpm -ivh *.rpm
  6. 如果要安装mysql-community-test-5.7.37-1.el7.x86_64.rpm则需要执行
    yum -y install perl
    yum -y install net-tools
    yum -y install per-JSON
    yum -y install autoconf
  7. 查看mysql-server安装的文件列表
    rpm -ql mysql-community-server-5.7.37
  8. 查看默认密码
    cat /var/log/mysqld.log |grep password
    [root@slave1 mysql57]# cat /var/log/mysqld.log |grep password
    2022-02-03T09:59:22.090885Z 1 [Note] A temporary password is generated for root@localhost: AJDtlg*kM1W1
  9. 关闭validate_password插件
    vim /etc/my.cnf最后添加validate_password=OFF
    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
    
    [mysqld]
    #
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
    #
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    # log_bin
    #
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    validate_password=OFF #新添加
  10. 登录mysql
    mysql -uroot -p回车输入/var/log/mysqld.log中的密码

  11. 设置密码(需要关闭密码验证插件validate_password=OFF)
    set password for root@localhost=password('123456');

  12. 查看mysql现有账号
    use mysql;
    mysql> select user,host from user;
    +---------------+-----------+
    | user          | host      |
    +---------------+-----------+
    | mysql.session | localhost |
    | mysql.sys     | localhost |
    | root          | localhost |
    +---------------+-----------+
    3 rows in set (0.00 sec)

  13. 添加远程账号

    mysql> grant all privileges on *.* to root@'%' identified by 'admin888';
    Query OK, 0 rows affected, 1 warning (0.00 sec)

    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

  14. centos添加3306端口
    [root@slave1 mysql57]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
    success
    [root@slave1 mysql57]# firewall-cmd --reload
    success
     

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值