• 【Mac + Mysql + Navicat Premium】之Navicat Premium如何连接Mysql数据库


    参考文章:

    《mac用brew安装mysql,设置初始密码》

    因为我需要连接数据库工具,需要密码,所以下面介绍如何设置、修改密码实现Navicat Premium连接Mysql数据库

    建议生产环境中mysql安装这完成后一定要运行一次mysql_secure_installation,在这里可以第一次设置密码,后续修改密码规则时可以多次修改密码,见下面:二、修改密码规则以及多次修改密码(但是,如果设置密码太简单低级会遇到密码策略问题,参考文章

    一、安全配置设置初始密码

    启动mysql

    mysql.server start

    设置密码:

    mysql_secure_installation

    运行mysql_secure_installation会执行几个设置:

    a)为root用户设置密码

    b)删除匿名账号

    c)取消root用户远程登录

    d)删除test库和对test库的访问权限

    e)刷新授权表使修改生效

    代码如下:

    Securing the MySQL server deployment.
    
    Connecting to MySQL using a blank password.
    
    VALIDATE PASSWORD COMPONENT can be used to test passwords
    and improve security. It checks the strength of password
    and allows the users to set only those passwords which are
    secure enough. Would you like to setup VALIDATE PASSWORD component?
    
    Press y|Y for Yes, any other key for No: y ==》输入y
    
    There are three levels of password validation policy:
    
    LOW    Length >= 8
    MEDIUM Length >= 8, numeric, mixed case, and special characters
    STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file
    
    Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0  ==》选择高中低密码,我选的0低级
    Please set the password for root here.
    
    New password:  ==》输入新密码
    
    Re-enter new password: ==》再次输入新密码
    
    Estimated strength of the password: 50 
    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y ==》安全只有50,输入y
    
    Password updated successfully!
    
    Reloading privilege tables..
    
    … Success!
    
    By default, a MySQL installation has an anonymous user, allowing anyone
    
    to log into MySQL without having to have a user account created for
    
    them. This is intended only for testing, and to make the installation
    
    go a bit smoother. You should remove them before moving into a
    
    production environment.
    
    Remove anonymous users? [Y/n]<– 是否删除匿名用户,生产环境建议删除,所以直接回车
    
    … Success!
    
    Normally, root should only be allowed to connect from 'localhost'. This
    
    ensures that someone cannot guess at the root password from the network.
    
    Disallow root login remotely? [Y/n]<–是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
    
    … Success!
    
    By default, MySQL comes with a database named 'test' that anyone can
    
    access. This is also intended only for testing, and should be removed
    
    before moving into a production environment.
    
    Remove test database and access to it? [Y/n]<– 是否删除test数据库,直接回车
    
    - Dropping test database…
    
    … Success!
    
    - Removing privileges on test database…
    
    … Success!
    
    Reloading the privilege tables will ensure that all changes made so far
    
    will take effect immediately.
    
    Reload privilege tables now? [Y/n]<– 是否重新加载权限表,直接回车
    
    … Success!
    
    Cleaning up…
    
    All done! If you've completed all of the above steps, your MySQL
    
    installation should now be secure.
    
    Thanks for using MySQL!
    
    [root@server1 ~]#

    初始密码设置成功,验证一下,登陆mysql:

    #登陆mysql
    mysql -u root -p

    输入密码:xxxx

    能进入就成功了!!!

    二、修改密码规则以及可以多次修改密码

    再返回到Navicat Premium中,

      

    2059 - Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(../Frameworks/caching_sha2_password.so, 2): image not found

     

    解决上面问题参考:《Navicat连接数据库MySQL报错2059

     

    是密码规则问题,解决问题如下: 

    #登陆mysql
    mysql -u root -p
    
    #输入密码
    Enter password: xxx
    
    #修改加密规则
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
    
    #更新一下用户的密码
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
    
    #刷新权限 
    FLUSH PRIVILEGES;

    效果图:

     

    但是,重新连接Navicat Premium时,还是报错

    1045 - Access denied for user 'root'@'localhost' (using password: YES)

     

     

    是因为,我上一步在更新密码中又把密码设置为“password”了,所以重新输入密码,再连接

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    C#延时
    Java Applet 绘图
    C#调用ActiveX控件异常处理
    J2SE连连看
    基于对象的棋类程序结构设计
    MATLAB应用专题part2电力电子仿真技术
    MATLAB应用专题part1电力电子仿真技术
    硬件知识整理part2电阻在反馈网络中的应用
    C语言再学习part1宏观认识C语言
    C语言再学习part3—算法
  • 原文地址:https://www.cnblogs.com/Owen-ET/p/9639592.html
Copyright © 2020-2023  润新知