网页显示连接mysql库失败

问题遇到的现象和发生背景

打开网页http://www.bjelf.com/
网页显示连接mysql库失败,请确定数据库用户名,密码设置正确

Can't connect to MySQL server on 'bjelf.com' (10061)
2003

问题相关代码,请勿粘贴截图

img

怎么解决

看你的意思,是别人的网站?那你处理不了。
如果是你自己的网站,那就确定一下数据库连接的账号密码对不对就好了呀。

就你这样,只能按字面意思解决呗

按他提示,怎么确定数据库用户名,密码设置正确

检查下后台数据库连接用户名密码是否正确

看看这2个解决方案吧,一样的错误
https://kalacloud.com/blog/can-t-connect-to-mysql-server-on-ipaddress-10061/
https://www.jb51.net/article/26505.htm

数据库连接的用户名或密码不对,怎么确定?数据库用户名、密码都不知道吗,先用数据库客户端连接测试一下。

是不是mysql服务没启动

是你自己的网站吗?如果是是自己的网站就按照报错处理。

有如下3个原因:
1、数据库连接地址出错
2,数据库用户名和密码错误
3,mysql服务器没有启用

数据库没连接上,你的连接参数不对

你这个网页链接没有任何让输入用户名密码的地方,建议你先用数据库客户端连接试试

你用户名密码的问题。 现在线下测试一下,在使用网页。

首先你得检查你的mysql是不是启动的,第二检查账号、密码是否正确,最后再检查代码中连接方式是否正确

[root@gree135 ~]# systemctl restart network.service

[root@gree135 ~]# yum install -y wget

[root@gree135 ~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

[root@gree135 ~]# yum localinstall mysql57-community-release-el7-8.noarch.rpm

[root@gree135 ~]# yum install mysql-community-server

[root@gree135 ~]# systemctl start mysqld
[root@gree135 ~]# systemctl enable mysqld
[root@gree135 ~]# systemctl daemon-reload
[root@gree135 ~]# systemctl stop firewalld
[root@gree135 ~]# systemctl disable firewalld
[root@gree135 ~]# grep 'temporary password' /var/log/mysqld.log
2021-10-08T03:21:28.093080Z 1 [Note] A temporary password is generated for root@localhost: 2qdMM&vmgRTB

[root@gree135 ~]# mysql -uroot -p
Enter password:

#设置密码报错,密码不符合安全等级
mysql> alter user 'root'@'localhost' identified by 'root';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

#设置mysql密码安全等级
mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

#重新设置密码成功
mysql> alter user 'root'@'localhost' identified by 'root';
Query OK, 0 rows affected (0.00 sec)

exit退出重新登陆,使用新密码

#设置远程登陆
mysql> grant all privileges on . to 'root'@'%' identified by 'root' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

1.后端是用什么语言写的。

有没有可能打开方式不对
https://blog.csdn.net/rej177/article/details/123151953?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165923938016782395359488%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165923938016782395359488&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-1-123151953-null-null.article_score_rank_blog&utm_term=mysql&spm=1018.2226.3001.4450