当前位置:网站首页>linux中mysql 1045错误如何解决
linux中mysql 1045错误如何解决
2022-06-29 17:16:00 【亿速云】
linux中mysql 1045错误如何解决
这篇文章主要介绍了linux中mysql 1045错误如何解决的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇linux中mysql 1045错误如何解决文章都会有所收获,下面我们一起来看看吧。
解决方法:1、登录数据库之后,利用“select host,user from user;”语句查询用户和权限;2、利用“grant select,update,insert,delete on mas.* to 新建用户@localhost identified by "密码";”语句添加普通权限的用户,重新登录mysql数据库即可。
本教程操作环境:linux7.3系统、mysql8.0.22版本、Dell G3电脑。
linux中mysql的1045错误解决的方法
开始使用Linux连接mysql数据库的时候,出现了1045错误。当出现这个问题的时候,应该是用户被数据库拒绝访问了,我们应该为你的数据库开辟权限。
1、查询数据库用户权限
登录数据库输入linux指令
mysql -uroot -padmin
登录你的数据库输入用户名和密码
使用数据库,查询权限
mysql> use mysql;
mysql> select host,user from user;

可以查询用户和权限
2、想要远程mysql服务器,需要增加普通权限的用户
mysql> grant select,update,insert,delete on mas.* to [email protected] identified by "admin";
grant select,update,insert,delete on mas.* to 新建用户@localhost identified by "密码";
这句命令的意思是:新建用户root,并且只允许该用户在本地(localhost)登录,密码是admin,并且赋予它对mas库中所有表select,update,insert的权限。我们在这有一个mas库,所以用mas.*代表mas库下的所有表。 现在该root用户,已经可以登录mysql了,但是也还是只能本地登录。
若要想root用户可以远程登录mysql,则还需要以下命令:
mysql> update user set host = '%' where user = 'root';
我们也可以直接给用户权限
grant all on *.* to 用户名@"%" identified by "密码";
flush privileges;刷新权限
关于“linux中mysql 1045错误如何解决”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“linux中mysql 1045错误如何解决”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注亿速云行业资讯频道。
边栏推荐
- Word2vec vector model of Wiki Chinese corpus based on deep learning
- 函数计算异步任务能力介绍 - 任务触发去重
- 元代理模型可迁移对抗攻击
- 如何在 PowerPoint 中向幻灯片添加 SmartArt?
- Paper notes: e (n) equivariant graph neural networks
- Kali installation tutorial 2020
- C语言练习----指针字符串、链表
- 腾讯云发布自动化交付和运维产品Orbit,推动企业应用全面云原生化
- Collaborative development of epidemic home outsourcing project 𞓜 community essay solicitation
- 卷妹带你学数据库---5天冲刺Day1
猜你喜欢

垃圾收集器

如何创建虚拟形象

Redis principle - sorted set (Zset)
![[R language data science]: Text Mining (taking Trump's tweet data as an example)](/img/4f/09b9885915bee50fb40976a5002730.png)
[R language data science]: Text Mining (taking Trump's tweet data as an example)

Collaborative development of epidemic home outsourcing project 𞓜 community essay solicitation

In depth analysis of Monai (I) data and transforms

Redis 原理 - Sorted Set (ZSet)
![[untitled]](/img/e2/be57a7e22275af59183c50e0710837.png)
[untitled]

机器学习8-人工神经网络

About xampp unable to start MySQL database
随机推荐
windows平台下的mysql启动等基本操作
0基础自学STM32(野火)——使用寄存器点亮LED——GPIO功能框图讲解
6.25AtCoderABC257E - Addition and Multiplication 2题解
@Difference between component and @configuration
Subgraphs in slam
Summary of problems during xampp Apache installation
Leetcode 984. 不含 AAA 或 BBB 的字符串(网友思路)
KUKA robot external axis configuration what you must know
Help MySQL data analysis with databend
Kubernetes deployment dashboard (Web UI management interface)
Advanced webgl performance optimization
Which is better and safer, GF e-gold or Dongfang fortune
Redis bloom filter and cuckoo filter
机器学习7-支持向量机
Possible reasons for not triggering onreachbutton
Freedom自由协议质押挖矿系统开发
关于onReachButton 不触发可能原因
LeetCode 每日一题——535. TinyURL 的加密与解密
卷妹带你学jdbc—2天冲刺Day1
腾讯云发布CDW ClickHouse升级版,为海量数据实时分析场景提供极速体验