2014-07-13 16:28:09
来 源
中存储网
Linux
(1) 启动mysql:# /etc/init.d/mysqld start(2) 进入mysql客户端:# mysql(3) 创建数据库TestDBmysql> create database TestDB;(4) 制定TestDB数据库为当前默认数据库my
(1) 启动mysql:
# /etc/init.d/mysqld start
(2) 进入mysql客户端:
# mysql
(3) 创建数据库TestDB
mysql> create database TestDB;
(4) 制定TestDB数据库为当前默认数据库
mysql> use TestDB;
(5) 在TestDB数据库中创建表customers
mysql> create table customers(userid int not null, username varchar(20) not null);
(6) 显示数据库列表
mysql> show databases;
(7)显示数据库中的表
mysql> show tables;
(8)删除表customers
mysql> drop table customers;
(9)显示customers表的结构
mysql> desc customers;
(10) 向customers表中插入一条记录
mysql> insert into customers(userid, username) values(1, 'hujiahui');
(11) 让操作及时生效;
mysql> commit;
(12) 查询customers中的记录
mysql> select * from customers;
(12) 更新表中的数据
mysql> update customers set username='DennisHu' where userid=1;
(13) 删除表中的记录
mysql> delete from customers;
(14)授予hjh用户访问数据库的权限
# grant select, insert, update, delete on *.* to hjh@localhost indentified by "123456";
备注:hjh是Linux用户名,123456是访问mysql的密码
(15)采用用户名和密码登录mysql
# mysql -uhjh -p123456
 

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。