2.create database student(数据库名) //创建数据库student
3.use student //进入student数据库
4.create table studinfo(表名) (sno int primary key,sage int(2))
............ // 创建表studinfo
5.show table//显示表
..............
6.drop database student//删除student数据库
一、用PhpMyAdmin新建一个MySQL用户.1,用root登陆phpmyadmin
2,点权限
3,点创建一个用户
4,选择所有权限
执行
二、使用可视化 *** 作软件,如phpmyadmin,mysqlcc等。
或者用命令行Create Database 数据库名
三、for example
创建用户vap,并分配权限:对数据库vap的所有表可以从所有机器(第一句)和本地机器(第二局)进行访问,并拥有任意权限,密码为vap
grant all privileges on vap.* to 'vap'@'%' identified by 'vap'
grant all privileges on vap.* to 'vap'@'localhost' identified by 'vap'
先mysql_connect()到mysql再做mysql_query()的相关 *** 作。====================================================================
<?php
$server = "localhost"
$username = "root"
$password = ""
$database = "myabc"
$ranks = array(
1=>"newbie",
2=>"new member",
3=>"member",
4=>"high member",
5=>"very high member",
6=>"supreme member",
7=>"ultra member",
8=>"godlike member",
9=>"god member",
10=>"low god",
11=>"medium god",
12=>"high god",
13=>"very high god",
14=>"supreme god",
15=>"ultra god",
16=>"perfect"
)
$couldNotOpenDatabase = "Could not open database<BR>\n please check your settings in config.php"
$couldNotConnectMysql="Could not connect Mysql!"
$conn=mysql_connect($server,$username,$password) or die ($couldNotConnectMysql)
if (mysql_select_db($database,$conn))
{//数据库存在,做相应 *** 作
}
else
{//数据库不存在,创建一个,并做相应 *** 作
$query = "CREATE DATABASE $database"
$result = mysql_query($query)
mysql_select_db($database,$conn)or die ($couldNotOpenDatabase)
}
?>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)