Databases Reference
In-Depth Information
Using a PHP-Enabled Web Hosting Site
There are a large number of companies that offer low-cost or free web hosting packages
with PHP and MySQL support. To start looking for one, perform a web search for
“php mysql web hosting.” These hosting packages usually include FTP access to copy
files to your web directory, and a web-based MySQL client such as phpMyAdmin.
To get your site up and running on such a site, first copy your files across to the server
using FTP. Under Linux, the KDE Konqueror and GNOME Nautilus file managers
both support FTP. Under Mac OS X, select “Connect to Server” from the Finder Go
menu; you can also use the free Cyberduck program. Under Windows, you'll need to
download an FTP tool such as FileZilla ( http://sourceforge.net/projects/filezilla ).
To connect to the server, enter your username and the name of your FTP server—for
example, ftp://adam@isp_ftp_server.net . If you're a power user and want command-
line control, including possibly scripting file transfers, you can use the ncftp tool set
( http://www.ncftp.com/ncftp ), especially the ncftpput program. This is the tool we use
ourselves, and is available for Linux, Windows, and Mac OS X.
Now, how do you set up the database? Well, there are two ways. You could create the
database on the web host; this is likely to be tedious. A better solution is to create the
database on your own machine and then export it to the web host.
You can export data from a database into an SQL dump file using the mysqldump com-
mand discussed in Chapter 10. Once you have the dump file, you can upload it to the
server as an SQL query text file. The server will run all the SQL queries in the file and
re-create the database.
Hosting companies generally don't give subscribers access to the MySQL server root
account and instead allocate each subscriber a non- root username and password. You'll
need to modify your scripts to use the authentication details provided to you.
Most web-hosting packages with MySQL support allow you to access the MySQL
server using the phpMyAdmin web-based MySQL administration tool. As you can see
from Figure 13-6, phpMyAdmin allows you to perform common operations such as
creating, browsing, editing, and dropping database tables by clicking on links in your
browser. You can run SQL queries on the database by typing them into the phpMyAd-
min text box or by uploading a text file that contains the query. You can upload a
complete database in this way by telling phpMyAdmin to run the queries in a database
dump file created using mysqldump .
Similarly, you can download a dump file of selected tables or the complete database by
selecting the “Save as file” option under the “View dump” section.
The XAMPP integrated package includes an installation of phpMyAdmin. Note that if
you configure web tools such as phpMyAdmin to access the server, you should take
great care to authenticate users, since you are effectively publishing your database on
the Web.
 
Search WWH ::




Custom Search