[英]mysql connect - Moving my website to a local host
I've created a website using a CMS. 我已经使用CMS创建了一个网站。 I've been making updates to the live site and, finally after months of "tsk tsk" from my dev friends have decided to create a local version on my computer to test updates on before making live.
我一直在对实时站点进行更新,最终,经过我的开发者朋友数月的“ tsk tsk”,我决定在我的计算机上创建本地版本,以在进行实时更新之前测试更新。
I copied all of the files and the DB to a folder. 我将所有文件和数据库复制到一个文件夹中。 Then, using XAMPP transferred the files to local host
然后,使用XAMPP将文件传输到本地主机
> http://localhost/mywebsite/
I then created a new database in phpmyadmin called "mywebsite" and imported the downloaded database successfully. 然后,我在phpmyadmin中创建了一个名为“ mywebsite”的新数据库,并成功导入了下载的数据库。
Now, when I navigate to 现在,当我导航到
> http://localhost/mywebsite/
I receive the following message: 我收到以下消息:
An error was detected which prevented the loading of this page.
检测到错误,阻止了该页面的加载。 If this problem persists, please contact the website administrator.
如果此问题仍然存在,请联系网站管理员。 core.error_file_line mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'mywebsitecom.fatcowmysql.com' (1)
core.error_file_line mysql_connect()[function.mysql-connect]:未知的MySQL服务器主机'mywebsitecom.fatcowmysql.com'(1)
Presumably I must link the database with the CMS on my computer. 大概我必须将数据库与计算机上的CMS链接起来。 I imagine that this must sound very simple to most people on Stack Overflow but my PHP and DB skills are limited.
我想这对大多数使用Stack Overflow的人来说听起来很简单,但是我的PHP和DB技能却很有限。
Is it immediately apparent to anybody what actions I need to take next to complete local set up? 对任何人来说,立即显而易见的是,接下来我需要采取什么行动才能完成本地设置?
In your mysql_connect
call you are giving it mywebsitecom.fatcowmysql.com
as a host, locate your code file where you connect to MySQL and change that value to localhost
在
mysql_connect
调用中,您将其mywebsitecom.fatcowmysql.com
为mywebsitecom.fatcowmysql.com
作为主机,找到您连接到MySQL的代码文件,并将该值更改为localhost
like 喜欢
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
Better not to use mysql_*
functions anyway :) 最好还是不要使用
mysql_*
函数:)
You're attempting to connect to a MySQL server at mywebsitecom.fatcowmysql.com, even though said server probably disallows external connections for security reasons. 您正在尝试通过mywebsitecom.fatcowmysql.com连接到MySQL服务器,即使该服务器出于安全原因可能不允许外部连接。 Try connecting to "localhost" instead of "mywebsitecom.fatcowmysql.com".
尝试连接到“ localhost”,而不是“ mywebsitecom.fatcowmysql.com”。 That should work, provided you have MySQL installed on your local system.
只要您在本地系统上安装了MySQL,就可以使用。 Depending on what CMS you're using, you should be able to edit a configuration file somewhere.
根据所使用的CMS,您应该可以在某处编辑配置文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.