sách gpt4 ăn đã đi

Cơ sở dữ liệu Mysql không thể được kết nối bằng "loclhost", nhưng có thể được kết nối bằng "127.0.0.1" Centos 7 (Cloudlinux)

In lại Tác giả: Walker 123 更新时间:2023-11-29 15:21:36 28 4
mua khóa gpt4 giày nike

我的操作系统:Centos 7 + CLOUDLINUX 7.7当我尝试从服务器登录Mysql时

[root@server3 ~]# Mysql -u root -h localhost -P 3306 Working ok 
[root@server3 ~]# Mysql -u root -h 127.0.0.1 -P 3306 Working Ok

但是当我在托管域“xyz.com”上使用 localhost 时,其中 DB Host =“localhost”它无法连接,当我将其更改为 DB Host =“127.0.0.1”时,它连接到数据库

[root@server3 ~]# cat /etc/hosts
127.0.0.1 localhost
::1 localhost localhost6.localdomain6 localhost6
[root@server3 ~]# ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.044 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.056 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.079 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.064 ms
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

Có giải pháp nào không?

câu trả lời hay nhất

当使用 IP 地址 (127.0.0.1) 时,MySQL 通过 TCP/IP 连接,当使用 localhost 时,使用套接字文件。在您的情况下,我想您的 mysql.sock 位于某个特殊位置,并且无法从 CageFS 内部获取。默认情况下使用 /var/lib/mysql/

如果是这样 - 请将该目录添加到 /etc/cagefs/cagefs.mp 文件中,然后运行 cagefsctl --remount-all

问题修复

关于Mysql 数据库无法使用 "loclhost"连接,但可以使用 "127.0.0.1"Centos 7 (Cloudlinux) 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59347560/

28 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress