SpringBoot 实现数据库主从 读写分离,及Mysql 详细安装步骤 (基于Mybatis,Mysql)

SpringBoot 实现数据库主从 读写分离,及Mysql 详细安装步骤 (基于Mybatis,Mysql)

一、Mysql 详细安装步骤及授权等(MySQL 5.7)

  1、添加MySQL Yum仓库到系统仓库列表中。

    a、vi /etc/yum.repos.d/mysql-community.repo文件中编辑添加如下版本

    

# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

  d、使用命令(yum repolist enabled | grep mysql) 检查当前enabled的子仓库是否是你想要安装的版本。

    

       mysql-connectors-community/x86_64        MySQL Connectors Community           17
            mysql-tools-community/x86_64             MySQL Tools Community                29
            mysql56-community/x86_64                 MySQL 5.6 Community Server          199

   C、安装MySQL

      ps:附上安装时检查gpgkey的文件,放到/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql目录下保证 即可,也可以设置设置gpgcheck为0不检查

        // wget http://repo.mysql.com/RPM-GPG-KEY-mysql -O /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

      使用sudo yum install mysql-community-server)进行安装。 该命令同时会安装其他mysql-community-server
            需要的组件 例如mysql-community-client,mysql-community-common,mysql-community-libs

    D、启动MySQL

      sudo service mysqld start) 启动MySQL服务。

      sudo service mysqld status) 查看MySQL服务状态。

  二、启动MySQL常见错误

    1、MySQL5.6是密码为空直接进入数据库的,但是MySQL5.7就需要初始密码

        修改mysql的配置文件my.conf

       在文件的[mysqld]标签下添加一句:skip-grant-tables

     2,然后执行 mysql -uroot -p ,直接回车登陆,马上修改新的密码,如果出现错误

      mysql> use mysql;

        ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

     3,报错的意思就是你的密码不符合要求,如果你想要设置一个简单的测试密码的话,比如设置为123456

       mysql> alter user 'root'@'localhost' identified by '123456';

        ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

      4、授权访问

       mysql> grant all privileges on *.* to '用户名'@'%' identified by '密码' with grant option;

       最后刷新即可   mysql> flush privileges;

 

posted on 2021-09-16 11:04  雷先森o  阅读(623)  评论(0)    收藏  举报

导航