WordPress错误:在非默认端口上建立数据库连接MySQL

huangapple go评论52阅读模式
英文:

WordPress Error establishing a database connection MySQL on non-default port

问题

我正在尝试在我的本地主机上使用XAMPP安装WordPress。我的Apache模块在端口80、443上,我的MySQL模块在端口3307上(默认为3306)。我无法开始安装WordPress。在浏览器中输入localhost/wordpress后,出现错误“Error establishing a database connection”。我没有wp-config.php文件,我猜想它会在启动安装后创建,但我无法启动。

我尝试过修改wp-config-sample.php,但似乎没有改变任何东西。我还尝试过自己创建wp-config.php并在其中更改数据库详细信息。

英文:

I'm trying to install wordpress on my localhost with XAMPP. My Apache module is on ports 80,443 and my MySQL module is on port 3307 (default is 3306). I can't start installing wordpress. After entering localhost/wordpress in my browser there apears error "Error establishing a database connection". I don't have wp-config.php file i guess it creates after starting installation which i can't start

I tried changing wp-config-sample.php but it looks like it doesn't change anything i also tried creating wp-config.php on my own and changing DB details there

答案1

得分: 1

你需要修改的是config.php文件,而不是config-sample.php文件。

define( 'DB_NAME', 'your_dbname' );
define( 'DB_USER', 'your_dbuser' );
define( 'DB_PASSWORD', 'your_dbpasw' );
define( 'DB_HOST', 'localhost:3307' );

这就是你需要的全部。只需在localhost(或你的机器IP地址/主机名)后面添加“:”即可。

英文:

You have to change config.php not config-sample.php.

define( 'DB_NAME', 'your_dbname' );
define( 'DB_USER', 'your_dbuser' );
define( 'DB_PASSWORD', 'your_dbpasw' );
define( 'DB_HOST', 'localhost:3307' );

That's all you need. Just append ":" after localhost (or your machine ip address/host name)

答案2

得分: 0

出现数据库连接问题意味着正在使用一个名为“wp-config.php”的文件,而且凭据不正确——主机名、端口、凭据,或者可能尚未创建数据库。

在初始设置期间,WordPress将在连接成功时创建wp-config.php文件,其中包含MySQL凭据。如果您没有看到设置页面,请检查您的“wp-config.php”文件,或者删除所有内容,然后使用新的WordPress下载重新开始。解压缩zip/tar.gz存档,并将“wordpress/”文件夹中的内容移动到您站点的DocumentRoot中。

您还可以使用以下命令测试您的MySQL凭据:

mysql -h localhost -P 3307 -u DatabaseUsername -p

大写的“P”表示端口,小写的“p”表示密码。如果在提示符处输入密码成功,请检查是否有一个数据库使用show databases;

英文:

Having a database connection issue would mean there's a "wp-config.php" file being used, and the credentials are incorrect -- hostname, port, credentials, or possibly not having a database created yet.

During an initial setup, WordPress will create the wp-config.php file with the MySQL credentials, when the connection is a success. If you're not getting a setup page, review your "wp-config.php" file, or delete all of the contents and start over with a new WordPress download. Extract the zip/tar.gz archive, and move the contents in the "wordpress/" folder into your site's DocumentRoot.

You can also test your MySQL credentials with this command:

mysql -h localhost -P 3307 -u DatabaseUsername -p

The uppercase "P" is for port, and the lowercase "p" is for password. If entering the password at the prompt is successful, check that you've got a database with show databases;.

huangapple
  • 本文由 发表于 2023年2月6日 21:39:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/75362048.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定