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-server安装的文件列表
    rpm -ql mysql-community-server-5.7.37
  7. 查看默认密码
    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
  8. 关闭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 #新添加
  9. 登录mysql
    mysql -uroot -p回车输入/var/log/mysqld.log中的密码

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

  11. 查看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)

  12. 添加远程账号

    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)

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

上一篇:ORACLE学习笔记-CentOS 7.2 Oracle 12C R2安装部署


下一篇:Solve error: 'class vtkImageActor' has no member named 'SetInput'