分类: LINUX
2009-10-23 12:18:42
四.phpMyAdmin的安装与使用
phpMyAdmin是一款安装便捷,使用方便,操作简单,功能强大的MySQL图形化配置工具。
1.phpMyAdmin的安装
(1)获取phpMyAdmin安装包
phpMyAdmin是用PHP编制的一种客户端/服务器结构的软件包,事实上是一些放在服务器端的能够通过浏览器界面管理的页
面程序文件,因此,安装phpMyAdmin的过程实际上就是将其解压到一个允许执行PHP的目录下。
·在http://下载最新的phpMyAdmin版本,将其tar文件复制到/root目
录下。例如,下载phpMyAdmin-
·执行以下命令将tar文件解压缩:
#tar xvzf
phpMyAdmin-
·该命令执行后,root目录下将会生成一个子目录php phpMyAdmin-
phpMyAdmin-
#mv phpMyAdmin-
(2)修改主配置文件
phpMyAdmin的配置主要是通过修改配置文件config.inc.php。而根据上面的修改后该文件应当位于
/var/www/html/phpMyAdmin中。但刚拷贝而来的phpMyAdmin目录下,可能会并没有config.inc.php文件,而只有一个
config.sample.inc.php文件。此时,需要将config.sample.inc.php文件复制为config.inc.php文件:
#cp config.sample.inc.php config.inc.php
以下是config.inc.php中的部分内容,通过修改其中的一些选项,可以完成phpMyAdmin的配置:
$cfg['blowfish_secret'] = ''; //设置phpMyAdmin的认证信息。需要在字符串中填写phpMyAdmin的认证信息,实
际是一串 md5的校验码,在下载时获得。当用户验证方式为cookie方式,必须设置 //
$cfg['Servers'][$i]['host'] =
'localhost'; //设置MySQL数据库服务器的域名或IP地址。此处使用默认值“localhost”,
表示MySQL数据库服务器就在本地Linux系统中,值得注意的是,现在的
phpMyAdmin都支持对多个MySQL数据库服务器的管理,所以,增加了
['Servers'][$i]数组来存放不同服务器的连接信息。当$i=0时,对应着第一个
MySQL服务器;当$i=1时,对应着第二个MySQL服务器,以此类推。//
$cfg['Servers'][$i]['connect_type']
= 'tcp';
$cfg['Servers'][$i]['extension']
= 'mysql'; //设置连接数据库类型//
$cfg['Servers'][$i]['compress'] = FALSE;
$cfg['Servers'][$i]['auth_type']
= 'config'; //设置用户验证方式。有config, http ,cookie based几种方式//
$cfg['Servers'][$i]['password']
= '111'; //设置用户验证方式为config方式时的登录密码//
$cfg['UploadDir'] =
'';
$cfg['SaveDir'] =
'';
(3)安装测试
完成了上述设置后,要测试phpMyAdmin能否正常工作,可在本地浏览器的地址栏中输入:。如
果配置无误,则应该看到phpMyAdmin管理界面;若看到“无法载入mysql扩展,请检查PHP配置”,说明系统当前没有安装
php-mysql模块,则需使用以下命令进行安装:
#rpm -ivh php-pdo-
#rpm -ivh
php-mysql-
用户在输入用户名root及设置的相应密码111后,将打开phpMyAdmin访问MySQL服务器的初始网页。注意:如果用其他客户
CREATE DATABASE newDB
CREATE TABLE [database_name.[owner].|owner.]table_name
({
|
[ON{filegroup|DEFAUTLT}][TEXTIMAGE_ON{filegroup|DEFAULT}]
SELECT select_list [INTO new_table] FROM table_source [WHERE search_condition]
[GROUP BY group_by_expression]
[HAVING seagch_condition]
[ORDER BY orde_expression [ASC|DESC]]
SELECT CompanyName,ContactName,Address,Phone FROM customers
CREATE DATABASE newDB
SELECT * FROM Employees WHERE FirstName='Andrew'
SELECT * FROM Employees WHERE Country<>'USA'
SELECT * FROM Products WHERE UnitPrice>=18 AND UnitPrice<=40 或者
SELECT * FROM Products WHERE UnitPrice BETWEEN 18 AND 40
SELECT * FROM Employees WHERE city IN ('Seattle','London','Redmond')
SELECT * FROM Employees WHERE Region IS NULL
SELECT * FROM Employees WHERE Eegion IS NOT NULL
ASCII
|
NCHAR
|
SOUNDEX
|
CHAR
|
PATINDEX
|
SPACE
|
CHARINDEX
|
REPLACE
|
STR
|
DIFFERENCE
|
QUOTENAME
|
STUFF
|
LEFT
|
REPLICATE
|
SUBSTRING
|
LEN
|
REVERSE
|
UNICODE
|
LOWER
|
RIGHT
|
UPPER
|
LTRIM
|
RTRIM
|
|
例:用LEN函数求得city值为London的公司的名称字符串的长度
SET @string_to_trim=' five spaces are at the beginning of this string.'
SELECT 'Here is the string without the leading spaecs: ' + LTRIM(@string_to_trim)
显示:Here is the string without the leading spaecs: five spaces are at the beginning of this string.
SET @string_to_trim='four spaces are after the period in this snetence. '
SELECT 'Here is the string without the leading spaecs: ' + CHAR(13)+RTRIM(@string_to_trim)
显示:Here is the string without the leading spaecs:
four spaces are after the period in this snetence.
数学函数
ABS
|
DEGREES
|
RAND
|
ACOS
|
EXP
|
ROUND
|
ASIN
|
FLOOR
|
SIGN
|
ATAN
|
LOG
|
SIN
|
ATN2
|
LOG10
|
SQUARE
|
CEILING
|
PI
|
SQRT
|
COS
|
POWER
|
TAN
|
COT
|
RADIANS
|
|
结果:123.0 .0 7891.05
结果:3.1415926535897931 123.4567 1156.0 19.0
DATEADD
|
DATEDIFF
|
DATEPART
|
DATENAME
|
GETUTCDATE
|
GETDATE
|
DAY
|
MONTH
|
YEAR
|
从服务器上得到当前的日期和时间可以用GETDATE函数
FROM titles
SELECT select_list [INTO new_table] FROM table_source [WHERE search_condition]
[GROUP BY group_by_expression]
[HAVING search_condition]
[ORDER BY orde_expression [ASC|DESC]]
WHERE [Order Details].Productid=Products.Productid
WHERE Orders.Employeeid=Employees.Employeeid
简单的字母就可以代表这个表。
从订单表Order Details和产品表Products中得到订单编号Orderid,产品名称ProdcutName,订货数量Quantity和产品
FROM Orders AS o,Employees AS e,Customers AS c
WHERE o.Employeeid=e.Employeeid And o.Customerid=c.Customerid
FROM [Order Details] AS OD INNER JOIN Products AS P
FROM Orders AS o INNER JOIN Employees AS e ON o.Employeeid=e.Employeeid
INNER JOIN Customers AS c ON o.Customerid=c.Customerid
USE pubs
SELECT a.au_fname,a.au_lname,p.pub_name
FROM authors a LEFT OUTER JOIN publishers p ON a.city=p.city
ORDER BY p.pub_name ASC,a.au_lname ASC,a.au_fname ASC
SELECT a.au_fname,a.au_lname,p.pub_name
FROM authors AS a RIGHT OUTER JOIN publishers AS p ON a.city=p.city
ORDER BY p.pub_name ASC,a.au_lname ASC,a.au_fname ASC
SELECT a.au_fname,au.au_lname,p.pub_name
FROM authors a FULL OUTER JOIN publishers p ON a.city=p.city
ORDER BY p.pub_name ASC,a.au_lname ASC,a.au_fname ASC
USE Northwind
SELECT EmployeeID,CustomerID
FROM employees CROSS JOIN customers
ORDER BY EmployeeID
SELECT e.LastName AS 员工的名字,m.LastName AS 上司的名字
FROM Employees AS e LEFT JOIN Employees AS m
ON e.Reportsto= m.Employeeid