如何管理MySQL数据库?
来源:重庆广渝网 |
阅读:18077 次
|
日期:2005-08-03
|
A:MYSQL数据库的管理方式如下:
首先下载PhpMyAdmin软件,将此文件包解压,找到其中的一个文件:config.inc.php(或者如config.*等, 该文件名会因phpmyadmin版本不同, 而有所差别) 修改以下配置: $cfgServers[1]['host'] = 'localhost'; // MySQL hostname $cfgServers[1]['port'] = ''; // MySQL port - leave blank for default port $cfgServers[1]['socket'] = ''; // Path to the socket - leave blank for default socket $cfgServers[1]['connect_type'] = 'tcp'; // How to connect to MySQL server ('tcp' or 'socket') $cfgServers[1]['stduser'] = ''; // MySQL standard user settings (this user must have read-only $cfgServers[1]['stdpass'] = ''; // access to the "mysql/user" and "mysql/db" tables) $cfgServers[1]['adv_auth'] = FALSE; // Use advanced authentication? $cfgServers[1]['user'] = 'alintest'; // MySQL user $cfgServers[1]['password'] = 'alintest'; // MySQL password (only needed with basic auth) $cfgServers[1]['only_db'] = 'alintest'; // If set to a db-name, only this db is displayed at left frame
然后您ftp到您的网站, 在wwwroot下建立一个目录phpmyadmin, 把phpmyadmin所有文件上传到该目录下,访问 http://www.yourdomain.com/phpmyadmin, 即可对数据库进行管理。 在建好数据库后, 务必将这些phpadmin的文件移走, 否则任何人都可以管理用户的数据库。
若是采用用php编程, 可以用以下代码连接数据库: <?php $database = "alintest"; $user = "alintest"; $password = "alintest"; $link = mysql_connect ("localhost", $user, $password) or die ("Could not connect"); mysql_select_db($database, $link);
..........
mysql_close ($link); ?>
如果采用perl编程, 可以用如下代码连接数据库: #!/usr/bin/perl
use DBI; $database = "alintest"; $user = "alintest"; $password = "alintest"; $dbh = DBI->connect("DBI:mysql:$database", $user, $password);
..........
$rc = $dbh->disconnect;
如果需要mod_perl的功能的话, 可访问 http://www.youdromain.com/perl/yourcgi.cgi 把普通的/cgi-bin/改成/perl/; 而mod_perl的CGI目录和普通CGI目录是一样的, 都在 wwwroot/cgi-bin下.
例:把一个env.cgi的程序上载到 wwwroot/cgi-bin目录下: 如果用普通的方式访问, 那么URL为: http://www.yourdomain.com/cgi-bin/env.cgi 如果用mod_perl的方式访问,那么URL为: http://www.yourdomain.com/perl/env.cgi
|