当前位置:网站首页>使用navicat连接mysql数据库时常报的错误:2003、1698、1251
使用navicat连接mysql数据库时常报的错误:2003、1698、1251
2022-07-30 05:50:00 【m0_67402970】
连接不上数据库
error 1698
报错提示:ERROR 1698 (28000): Access denied for user 'root'@'localhost'
报错原因: 在安装mysql数据库的过程中未给root用户设置密码,导致不能登陆成功
解决措施: 设置数据库root用户密码
第一步:update mysql.user set authentication_string=PASSWORD('root'),plugin='mysql_native_password' where user='root';
第二步:flush privileges;
(刷新)
第三步:用root用户的新密码登录mysql
error 2003
报错提示:
第一种: 2003 - Can't connect to MySQL server on 'localhost'(10061 "Unknown error")
(本地连接数据库出错)
或者第二种:2003-cant connection to mysql server on ‘IP’(10061 unknown error)
(服务器远程连接出错:未知错误)
或者第三种:Can't connect to MySQL server on "IP地址'(10038)
(服务器远程连接数据库出错:防火墙出错)
报错原因:
第一个错误提示的原因:mysql服务未成功启动,所以连接不上
第二个错误提示的原因:注意这个10061 unknown error,表示未知错误,出错的原因可能是:(1)mysql服务未成功启动(2)配置文件出错
第三个错误提示的原因:报10038表示服务器防火墙没有开启3306端口
解决措施:
(1)针对第一个错误提示的解决:与mysql服务是否启动有关,去重新启动下服务:
方式一:右击计算机=>管理=>服务和应用程序=>服务=>找到MySQL服务,启动,甚至可以改为自启动,这样之后电脑开机后mysql服务就会自动启动了
方式二:或者在mysql安装目录的bin目录下输入命令net start mysql
启动mysql服务
(2)针对第二个错误提示的解决:(全程在服务器端操作)
第一步:先查看mysql服务是否开启,如果开启了,表示不是服务未启动的问题,则看第二步
第二步:登入mysql数据库:musql -u 用户 -p 密码
第三步:输入use mysql;
再输入:update user set Host='%' where User='root';
(这表示修改mysql库的user表,将host项,从localhost改为%。%这里表示的是允许任意host访问,如果只允许某一个ip访问,则可改为相应的ip。)
第四步:exit
命令退出数据库,服务器终端输入命令vim /etc/mysql/mysql.conf.d/mysqld.cnf
来打开配置文件mysqld.cnf
,修改43行的bind_address=127.0.0.1为bind_address=0.0.0.0
第五步:重启mysql服务,service mysql restart
(3)针对第三个错误提示的解决:
第一步:打开防火墙配置文件:vim /etc/sysconfig/iptables
第二步:将配置文件中的一行A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
中的80改为3306
第三步:重启防火墙:service iptables restart
error 1251
报错提示:1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client.
报错原因:发现是从MySQL8.0 高级版本的时候出现的问题,而8之前的低版本都还没有这个问题。MySQL8.0版本改变了密码的验证规则导致的问题。
解决措施:
第一步:更新密码alter user 'root'@'localhost' identified with mysql_native_password by '设置新密码';
注意:如果还是出错,就将localhost改为%,这样就可以解决了,解释:登录mysql数据库,使用use mysql; 命令后,再输入 select user,host form user; 查看root用户和它对应的host,有的数据库中的root对应的host是localhost,有的对应的host是%
第二步:刷新FLUSH PRIVILEGES
边栏推荐
- 预测人们对你的第一印象,“AI颜狗”的诞生
- 【MySQL】MySQL中如何实现分页操作
- The terminal connection tools, rolling Xshell
- Test development engineer growth diary 016 - those things about the test
- Data types of Redis6
- 上传文件--文件类型大全,图片类型,文档类型,视频类型,压缩包类型
- @Bean 与 @Component 用在同一个类上,会怎样?
- Multithreading basics (multithreaded memory, security, communication, thread pools and blocking queues)
- What happens when @Bean and @Component are used on the same class?
- STL源码剖析:临时对象的代码测试和理解
猜你喜欢
From catching up to surpassing, domestic software shows its talents
Huawei released "ten inventions", including computing, intelligent driving and other new fields
The calculation proof of the intersection of the space line and the plane and its source code
Let the "label" content in Baidu map generator expand--solution
(GGG)JWT
AI can identify race from X-rays, but no one knows why
Test Development Engineer Growth Diary 018 - Record of Required Questions for Test Interview (Continuous Update)
VR机器人教你如何正确打乒乓球
idea内置翻译插件
Graphical relational database design ideas, this is too vivid
随机推荐
DNS域名解析服务
prometheus-Federation机制配置
你被MySQL 中的反斜杠 \\坑过吗?
DNS domain name resolution services
什么是微服务?
华为发布“十大发明”,包含计算、智能驾驶等新领域
Redis download and installation
从追赶到超越,国产软件大显身手
向量叉乘的几何意义及其模的计算
When does MySQL use table locks and when does it use row locks?
MySQL master-slave replication configuration construction, one step in place
Redis下载与安装
向量的导数运算和向量叉乘以及点乘的导数运算
Linx common directory & file management commands & VI editor usage introduction
相机坐标系,世界坐标系,像素坐标系三者转换,以及OPENGLDEFocal Length和Opengl 的 Fov转换
Mobile phone side scroll to page to specify location
千万级数据量的表,怎样最快速度查询?
How to use Swagger, say goodbye to postman
Electron日常学习笔记
首届人工智能安全大赛正式启动