最简单mysql的使用方法


1、在shell下使用mysql,按照下面的方法。
$mysql -u

 1<your username=""> -p   
 2password:   
 3mysql&gt;show databases; //显示有哪些数据库   
 4mysql&gt;create DATABASE lll; //创建一个名为lll的数据库   
 5mysql&gt;use lll; //使用名为lll的数据库   
 6mysql&gt;show tables; //显示当前数据库中有哪些表   
 7mysql&gt;CREATE TABLE user (username TEXT not null , userpassword TEXT not null ) ; //创建一个表   
 8mysql&gt;ALTER TABLE user ADD email TEXT not null; //当前表增加一个字段   
 9mysql&gt;ALTER TABLE test DROP come; //当前表丢弃一个字段   
10mysql&gt;ALTER TABLE test CHANGE pass pass LONGTEXT not null; //更改当前表中的一个字段   
11mysql&gt;DROP TABLE user; //丢弃当前数据库中的一个表。 
12
132、php3代码实现数据库的创建;   

$dbc=mysql_connect("localhost","youruser","yourpassword");
mysql_create_db(zzz); //创建一个名为zzz的数据库
echo "成功";

13、使用php3创建一个表:   
2&lt;?php   
3$dbc=mysql_connect("localhost","root","");   
4mysql_select_db("zzz",$dbc);   
5mysql_query("CREATE TABLE user (username TEXT not null , userpassword TEXT not null )");</your>
Published At
Categories with 数据库类
Tagged with
comments powered by Disqus