当前位置:网站首页>使用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
边栏推荐
- Test development engineer growth diary 016 - those things about the test
- What happens when @Bean and @Component are used on the same class?
- Bull: remove common characters
- 阿里一面:多线程顺序运行有多少种方法?
- Test Development Engineer Growth Diary 001 - Some Introduction to Agile Testing, CI/CD/CT, DecOps
- Headline 2: there are several kinds of common SQL errors in MySQL usage?
- The CTO said I was not advised to use SELECT *, why is that?
- 矩阵的行列式的计算及其源码
- MySQL什么时候用表锁,什么时候用行锁?
- numpy 多维数组ndarray的详解
猜你喜欢

大飞机C919都用了哪些新材料?

STL源码剖析:迭代器的概念理解,以及代码测试。

idea built-in translation plugin

RAID disk array

numpy 多维数组ndarray的详解

Multithreading basics (multithreaded memory, security, communication, thread pools and blocking queues)

When does MySQL use table locks and when does it use row locks?

AI元学习引入神经科学,医疗效果有望精准提升

Advanced multi-threading (CountDownLatch, deadlock, thread-safe collection class)

STL源码剖析:临时对象的代码测试和理解
随机推荐
Derivative Operations on Vectors and Derivative Operations on Vector Cross and Dot Products
人工肌肉智能材料新突破
How does Redis prevent oversold and inventory deduction operations?
Upload file -- file type, picture type, document type, video type, compressed package type
Graphical relational database design ideas, this is too vivid
阿里二面:列出 Api 接口优化的几个技巧
numpy 多维数组ndarray的详解
Test the basics 01
使用 Grafana 的 Redis Data Source 插件监控 Redis
Required request body is missing problem solving
Ali two sides: List several tips for Api interface optimization
空间顶点到平面的距离计算的证明及其源码
matlab机器学习_01
Polygon 3D(三维平面多边形)的法向量的计算(MeshLab默认的计算)
计算矩阵的逆源码(使用伴随矩阵,3×3的矩阵)
No, the Log4j vulnerability hasn't been fully fixed yet?
软件测试术语 - 场景测试
MySQL主从复制配置搭建,一步到位
prometheus-Federation机制配置
The newcomer deleted data by mistake, and the team leader skillfully used MySQL master-slave replication to delay the recovery of losses