linux中创建mysql数据库命令_在linux下如何进⾏mysql命令
⾏创建数据库
-u和-p连接数据库⽤户和密码中间是不能有空格的
下⾯来创建数据库mydatabase
create database mydatabase;
这样⼀个名叫mydatabase的数据库就创建好了
show databases; 显⽰所有数据库列表
drop database mydatabase; 删除数据库mydatabase
那么如何退出mysql命令⾏呢?
在终端输⼊exit; 知道完全退出mysql命令⾏为⽌
附后⼀些常⽤的命令
(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的密码
在linux中下载mysql时冲突是什么(15)采⽤⽤户名和密码登录mysql
# mysql -uhjh -p123456

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。