5.导入数据库表
(1)创建.sql文件
(2)先产生一个库如auction.c:mysqlbin>mysqladmin -u root -p creat auction,会提示输入密码,然后成功创建。
(2)导入auction.sql文件
c:mysqlbin>mysql -u root -p auction < auction.sql。
通过以上操作,就可以创建了一个数据库auction以及其中的一个表auction。
6.修改数据库
(1)在mysql的表中增加字段:
alter table dbname add column userid int(11) not null primary key auto_increment;
这样,就在表dbname中添加了一个字段userid,类型为int(11)。
7.mysql数据库的授权
mysql>grant select,insert,delete,create,drop
on *.* (或test.*/user.*/..)
to 用户名@localhost
identified by '密码';
如:新建一个用户帐号以便可以访问数据库,需要进行如下操作:
mysql> grant usage
-> ON test.*
-> TO testuser@localhost;
Query OK, 0 rows affected (0.15 sec)
此后就创建了一个新用户叫:testuser,这个用户只能从localhost连接到数据库并可以连接到test 数据库。下一步,我们必须指定testuser这个用户可以执行哪些操作:
mysql> GRANT select, insert, delete,update
-> ON test.*
-> TO testuser@localhost;
Query OK, 0 rows affected (0.00 sec)
此操作使testuser能够在每一个test数据库中的表执行SELECT,INSERT和DELETE以及UPDATE查询操作。现在我们结束操作并退出MySQL客户程序:
mysql> exit
Bye
上一页 [1] [2]