
# mysql
(2) 启动mysql: 进入mysql控制的前提是保证mysql服务启动,如下命令可以启动mysql
# /etc/init.d/mysqld start
其它的mysql数据库相关的 *** 作如下
(1) 创建数据库TestDB
mysql>create database TestDB
(2) 制定TestDB数据库为当前默认数据库
mysql>use TestDB
(3) 在TestDB数据库中创建表customers
mysql>create table customers(userid int not null, username varchar(20) not null)
(4) 显示数据库列表
mysql>show databases
(5)显示数据库中的表
mysql>show tables
(6)删除表customers
mysql>drop table customers
(7)显示customers表的结构
mysql>desc customers
(8) 向customers表中插入一条记录
mysql>insert into customers(userid, username) values(1, 'hujiahui')
(9) 让 *** 作及时生效
mysql>commit
(10) 查询customers中的记录
mysql>select * from customers
(11) 更新表中的数据
mysql>update customers set username='DennisHu' where userid=1
(12) 删除表中的记录
mysql>delete from customers
(13)授予hjh用户访问数据库的权限
# grant select, insert, update, delete on *.* to hjh@localhost indentified by "123456"
备注:hjh是Linux用户名,123456是访问mysql的密码
(14)采用用户名和密码登录mysql
# mysql -uhjh -p123456
ctrl+alt+Fn 是控制台下的虚拟终端ctrl+alt+t 是伪终端,逻辑上的终端设备,多用于模拟终端程序, 通常是我们在X Window下打开的终端
运行命令tty即可区分。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)