navicat怎么连接mysql数据库_【Mac + Mysql + Navicat Premium】之Navicat Premium如何连接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]

… 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]

- 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中,

ab4dbe6faffcc7f602e229a4f6b3dc3d.png

3f1b918b7220e8842d507876b2f0b275.png

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

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

#登陆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;

效果图:

4302f3b731c1fadf01fb9d94a15f8bca.png

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

1d9235a3d2d66f8dbf6cbf12b9c4832b.png

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

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

2e85121bbf3041135d7b15c12f9c0fd1.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值