为MySQL配置DreamWeaver

While it’s not my preferred method for connecting to a MySQL server, writing queries, or displaying results (for reasons I will discuss shortly), using DreamWeaver’s “point-and-click” tools to create a MySQL connection does have the benefit of being fast and relatively easy to understand, making it a useful starting point for exploration of .

虽然这不是连接MySQL服务器,编写查询或显示结果的首选方法(出于我稍后将讨论的原因),但使用DreamWeaver的“点击”工具创建MySQL连接确实具有快速运行的优势。并且相对容易理解,这使其成为探索的有用起点。

If you want to use DreamWeaver's built-in methods for including MySQL data on a page, you first need to make sure that your DreamWeaver site is set up completely correctly: the smallest error in site configuration, even one that didn’t have any consequences before, will matter now. (I’m assuming for the purpose of this exercise that you have access to a MySQL server, and have already created a database table with some information.)

如果要使用DreamWeaver的内置方法在页面上包含MySQL数据,则首先需要确保完全正确 设置 DreamWeaver站点:站点配置中的最小错误,甚至是没有任何后果的错误。以前,现在很重要。 (出于本练习的目的,我假设您可以访问MySQL服务器,并且已经创建了包含一些信息的数据库表 。)

Next, create a new page and save it in your site folder. This will be the page on which we display the results of our database query. Getting to the point of displaying live database information on a web page will require three steps:

接下来,创建一个新的页面并将其保存在您的站点文件夹中。 这将是我们显示数据库查询结果的页面。 要在网页上显示实时数据库信息,将需要三个步骤:

  1. Providing DreamWeaver with information about our MySQL server, including a username and password for authorization.

    向DreamWeaver提供有关我们MySQL服务器的信息,包括用于授权的用户名和密码。
  2. Creating a query that interacts with a database table. (Extracting, inserting, or modifying data).

    创建与数据库表交互的查询。 (提取,插入或修改数据)。
  3. Displaying this data on the page.

    在页面上显示此数据。

On your new PHP page in DreamWeaver, switch into Design Mode. (While this step isn’t technically necessary, it will eliminate some possible distraction, and serve as an insightful final reveal at the end.)

在DreamWeaver的新PHP页面上,切换到设计模式 。 (尽管此步骤在技术上不是必需的,但它将消除一些可能的干扰,并在最后充当有见地的最终展示。)

DreamWeaver Insert Dynamic Table commandWe’re going to work backwards in this lesson, telling DreamWeaver that we want to put database information on a web page and then stepping through the procedures necessary to get there.  From the DreamWeaver menu, choose
Insert / Data Objects / Dynamic Table.

插入/数据对象/动态表

(“Dynamic” is just DreamWeaver’s way of saying “the information that is displayed comes from (or will be inserted into) a database”.)

(“动态”只是DreamWeaver所说的“显示的信息来自(或将要插入到)数据库中的信息”。)

DreamWeaver Check WindowA window will pop up checking that you have completed all the steps necessary to get to this stage. If your site is set up correctly, everything in the list should be ticked off except for the last step,
Create A Recordset. (“Recordset” is Dreamweaver’s term for a MySQL query). Click on that last link now.

创建记录集”外,所有列表中的所有内容均应勾选。 (“ Recordset”是DreamweaverMySQL查询术语)。 现在单击最后一个链接。

The window that now appears asks you to name the recordset. The name you use can be anything, so long as it follows the naming convention rules. The window then asks for for a connection, which you must create: click on Define, and then, in the window that appears, New.

现在出现的窗口要求您命名记录集。 您使用的名称可以是任何名称,只要它遵循命名约定规则即可 。 然后,该窗口会询问您必须创建的连接:单击定义 ,然后在出现的窗口中新建

DreamWeaver MySQL Connection windowYou should now see the
MySQL Connection window. Again, the name for your connection can be anything that follows the rules.

MySQL连接”窗口。 同样,连接的名称可以是遵循规则的任何名称。

For the MySQL server name:

对于MySQL服务器名称:

  • If you are on a web host that provides MySQL, the server name should have been provided to you: it is usually the same as the domain name, but does not have to be.

    如果您在提供MySQL的Web主机上,则应该已经为您提供了服务器名称:它通常与域名相同,但不必相同。

  • If you’re trying to connect to MySQL running  on your own machine (i.e. you’re running MAMP. XAMPP or some other local server setup) the server name will be localhost. You may need to add the port number to this: if so, the full information will be localhost:8888

    如果尝试连接到在自己的计算机上运行的MySQL (即,正在运行MAMP.XAMPP或其他本地服务器设置 ),则服务器名称将为localhost 。 您可能需要在此添加端口号:如果是这样,则完整信息将为localhost:8888。

  • If you’re in one of my classes, the server is webapp.ict.sait.ca (Note that you cannot reach this server from outside the SAIT campus).

    如果您在我的班级之一中,则服务器为webapp.ict.sait.ca (请注意,您无法从SAIT园区之外访问此服务器)。

You also need to enter your username and password for connecting to the database:

您还需要输入用户名和密码才能连接到数据库:

  • If you are on a web host that provides MySQL, the username and password is usually the same as those that you use for FTP, but does not have to be.

    如果您在提供MySQL的Web主机上,则用户名和密码通常与用于FTP的用户名和密码相同,但不必相同。

  • If you’re trying to connect to MySQL running on your own machine (i.e. you’re running MAMP. XAMPP or some other local server setup) the username will probably be root, with no password required.

    如果尝试连接到在自己的计算机上运行MySQL(即,正在运行MAMP。XAMPP或其他本地服务器设置),则用户名可能是root ,不需要密码。

  • If you’re in one of my classes, use the username and password you have been provided with.

    如果您属于我的班级之一,请使用提供的用户名和密码。

You’ll want to test this connection with the Test button, and then choose the database table you want to query information from. Keep with the basic query suggested by DreamWeaver for now.

您将要使用“ 测试”按钮测试此连接,然后选择要从中查询信息的数据库表。 暂时保留DreamWeaver建议的基本查询。

Dynamic Table on a DreamWeaver page in Design ViewThat should produce a basic dynamic table on your PHP page: the data within braces and highlighted in light blue in the page shown in Design Mode is DreamWeaver’s representation of data from the database, which will not be completed until the page is seen in a browser. (You should go ahead and do that now, using
File / Preview In Browser).

File / Preview in Browser来立即执行此操作 )。

Now switch to Code View; you’ll also want to open up the File window at the same time.  You’ll see several things:

现在切换到代码视图 ; 您还希望同时打开“ 文件”窗口。 您会看到几件事:

  • Code produced by DreamWeaverThe generated page uses an
    include, placed via a require_once function, that is given the name you provided for the connection above.

    include ,该包通过require_once函数放置,该包具有您为上述连接提供的名称。

  • This script is in a Connections folder; as an include, I would move it into the includes folder that should be part of your site structure.

    该脚本位于Connections文件夹中; 作为一个包含,我将其移动到应该包含在您的网站结构中的includes文件夹中。

  • The PHP closes and then immediately opens again. This is inefficient: PHP lines that are next to each should be in the same tag.

    PHP关闭,然后立即再次打开。 这是低效的:每行旁边PHP行应位于同一标记中。
  • The Connections script contains the username and password to the site in plaintext: for security purposes, you should put a .htaccess file that denies visitors into the folder, preventing them from reading this file.

    Connections脚本以纯文本形式包含该站点的用户名和密码为了安全起见,应放置一个 htaccess文件,拒绝访问者进入该文件夹,从而阻止他们读取此文件。

  • The PHP code produced is long and not terribly well documented; in reality, you could write this same script in three lines of code. (DreamWeaver is doing the same thing every WYSIWYG editor does, and over coding everything).

    生成PHP代码很长,并且没有很好的文档记录; 实际上,您可以用三行代码编写相同的脚本。 (DreamWeaver在每个WYSIWYG编辑器中都做同样的事情,并且对所有内容都进行了编码)。
  • Once you start editing this code DreamWeaver may protest that you’re “breaking” it, meaning that the point-and-click tools I’ve shown you may no longer continue to make changes to the code.

    一旦开始编辑此代码,DreamWeaver可能会抗议您“破坏”了它,这意味着我向您展示的点击工具可能不再继续对代码进行更改。

翻译自: https://thenewcode.com/427/Configuring-DreamWeaver-For-MySQL

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 要使用Dreamweaver连接MySQL,需要先安装MySQL数据库Dreamweaver软件。然后,按照以下步骤进行操作: 1. 打开Dreamweaver软件,选择“网站”菜单,点击“新建网站”。 2. 在“新建网站”对话框中,输入网站名称和保存路径,点击“下一步”。 3. 在“选择服务器技术”对话框中,选择“PHP/MySQL”,点击“下一步”。 4. 在“配置服务器连接”对话框中,输入MySQL数据库的主机名、用户名、密码和数据库名称,点击“测试连接”按钮,确认连接成功后,点击“下一步”。 5. 在“选择服务器模型”对话框中,选择“PHP MySQL”,点击“下一步”。 6. 在“网站设置”对话框中,设置网站的默认页面和其他选项,点击“完成”。 7. 在Dreamweaver的“文件”菜单中,选择“新建”,创建一个新的PHP文件。 8. 在PHP文件中,使用MySQL连接函数连接到数据库,执行SQL语句操作数据库。 以上就是使用Dreamweaver连接MySQL的步骤。 ### 回答2: Dreamweaver是一款用于网页设计和开发的软件,它可以轻松地与MySQL数据库进行连接,以便设计动态网站。下面是Dreamweaver连接MySQL的步骤: 第一步,打开Dreamweaver,选择“网站”并点击“站点管理器”按钮。接下来,点击“新建站点”按钮,并输入站点名称并选择站点的本地文件夹。 第二步,选择服务器技术:“PHP MySQL”,然后输入MySQL数据库的连接信息,包括主机名、用户名、密码、数据库名称等。 第三步,点击“测试”按钮测试数据库连接是否成功。如果连接成功,则会提示“连接成功”。 第四步,进入“应用程序”菜单,选择“数据库即时视图”,然后在右侧面板上选择“连接”选项卡。接下来,选择刚才创建的数据库连接,并测试连接是否成功。 第五步,如果连接测试成功,那么你可以通过“应用程序”菜单中的“绑定到数据”选项来实现数据绑定。在“绑定到数据”对话框中,选择要绑定到的MySQL数据库表格,并指定绑定方式,即可在网页上实现数据展示和交互。 总之,Dreamweaver连接MySQL数据库非常简单,只需按照以上步骤进行操作即可轻松连接数据库,并实现数据的绑定和交互。同时,Dreamweaver还提供了很多强大的工具和功能,方便设计师和开发者开发和维护网站。 ### 回答3: Dreamweaver是一款主流的Web开发IDE,支持连接和操作MySQL数据库。下面我们来了解如何在Dreamweaver中连接MySQL数据库。 首先,我们需要在服务器上安装MySQL,并在MySQL中创建数据库。然后,打开Dreamweaver并创建一个新的网站,选择“站点管理器”菜单中的“网站设置”选项。在弹出的对话框中,选择“服务器”并点击“+”按钮添加一个新的服务器。在“高级”选项中,选择“PHP MySQL”作为服务器模式。填写服务器地址、用户名、密码等信息,并测试连接。如果连接成功,会出现绿色的“已连接”标志。 接下来,在Dreamweaver中创建新的网页文件,并将其保存在网站目录中。在“视图”菜单中,选择“网站”选项,打开“数据库”面板。在面板左边的菜单中,选择“连接”并点击“+”按钮添加新的数据库连接。填写数据库名称、用户名、密码等信息,并测试连接。连接成功后可以查看数据库中的表结构。 现在,我们可以在网页中使用PHP语言和MySQL数据库进行数据交互。例如,可以使用MySQL查询语句在网页中显示数据库中的数据,或者使用PHP编写表单并将其提交到MySQL数据库中。 需要注意的是,Dreamweaver默认使用的是MySQL的标准SQL查询语句,不支持特定数据库供应商的扩展功能。如果需要使用特定数据库供应商的功能(如Oracle的分页查询),需要手动编写SQL查询语句。 在开发网站时,连接和操作MySQL数据库是必不可少的一部分。Dreamweaver提供了简单而方便的连接MySQL数据库的功能,帮助开发者快速完成Web应用程序。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值