centos7 installation mysql5.7 version (full)

centos installation

Imprint: centos7, mysql5.7, not centos7 Some commands may not be compatible

  1. Install mysql-server

    # 下载并安装 mysql yum 
    wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
    yum -y install mysql57-community-release-el7-10.noarch.rpm
    
    # 安装 mysql-server
    yum -y install mysql-community-server
  2. mysql initial installation of some configuration

    # 启动 mysql-serer 
    systemctl start mysqld.service
    # 查看是否启动成功,即是否存在 3306 端口
    netstat -tnlp | grep 3306
    # 查询 root 密码,登录到 mysql
    grep "password" /var/log/mysqld.log
    mysql -uroot -p 
    
    # 首次操作要求重置密码,必须大小写特殊字符组成
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
    
    # 授权远程访问 % 表示所有主机都可以访问
    mysql> grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
    # 刷新权限信息
    mysql> flush privileges; 
  3. Modify the character set

    vi /etc/my.cnf
    
    [client]
    default-character-set=utf8
    
    [mysqld]
    character-set-server=utf8
    collation-server=utf8_general_ci
    
    # 重启 mysql 
    systemctl restart mysqld.service
    
    # 查看是否配置成功
    mysql> status; 
    
    Server characterset:    utf8
    Db     characterset:    utf8
    Client characterset:    utf8
    Conn.  characterset:    utf8
  4. Configuration You can use weak passwords

    Mysql after upgrading to version 5.7, the passwords are strengthened

    • mysql.user modify the password field authentication_string
    • Adds password authentication plug-in
    # 查看当前密码规则
    mysql> show variables like 'validate_password%';
    +--------------------------------------+--------+
    | Variable_name                        | Value  |
    +--------------------------------------+--------+
    | validate_password_check_user_name    | OFF    |
    | validate_password_dictionary_file    |        |
    | validate_password_length             | 8      | 密码最小长度
    | validate_password_mixed_case_count   | 1      | 密码大写小写混合个数
    | validate_password_number_count       | 1      | 密码数字个数
    | validate_password_policy             | MEDIUM | 密码检查等级
    | validate_password_special_char_count | 1      | 密码特殊字符个数
    +--------------------------------------+--------+

    There are two solutions, one is to change the validation rules, the second is a direct uninstall password authentication plug-in

    • Uninstall password authentication plug-in

      mysql> uninstall plugin validate_password;
    • Modify validation rules

      mysql> set global validate_password_policy=0;
      mysql> set global validate_password_mixed_case_count=0;
      mysql> set global validate_password_number_count=3;
      mysql> set global validate_password_special_char_count=0;
      mysql> set global validate_password_length=3;

Modify the mysql password

If you are already logged in mysql, you can change the password directly

# 方法一. 设置当前登录用户密码
mysql> set password=password('newpassword');
# 方法二. 直接改用户表
mysql> use mysql;
mysql> update user set authentication_string=password('123abc') where user='root';
# 方法三. 修改密码
mysql> alter user root@'localhost' identified by '123456';

If you do not log in mysql, you can skip the check permission to modify the password

vi /etc/my.cnf
[mysqld]
skip-grant-tables

# 然后重启 mysql,不需要 root 密码登录 mysql ,之后随便你怎么玩 

windows installation

In general NEXT NEXT get away, but then I could download a test version, there is a 1045 error, it estimated the current version is not right. In fact, the solution is to skip the permissions check, reset your password, here to give the novice a method of operation

1. 先停止 mysql 服务,然后 cmd 到 mysql 的 bin 目录
2. mysqld -nt --skip-grant-tables
3. 启动 mysql 执行 mysqladmin -u root flush-privileges password <password>

Little promotion

Writing is not easy, I hope the support of open source software, and my gadgets, welcome to gitee point star, fork, put bug.

Excel common import and export, support Excel formulas
blog address: https://blog.csdn.net/sanri1993/article/details/100601578
gitee: https://gitee.com/sanri/sanri-excel-poi

Use the template code, the gadget generate code from the database, and some projects can often be used in the
blog address: https://blog.csdn.net/sanri1993/article/details/98664034
gitee: https://gitee.com/ sanri / sanri-tools-maven

Guess you like

Origin www.cnblogs.com/sanri1993/p/11704103.html