重新查看当前有哪些数据库

互联网 19-10-24

重新查看当前有哪些数据库

首先打开cmd,输入net start mysql启动mysql服务,然后输入mysql -hlocalhost -uroot -p回车登录数据库,之后就可以输入命令了。

MySQL命令行有很多命令,其中查看有哪些数据库,我们可以使用show databases;命令进行查看,注意分号不要忘了。

如果在此之前你使用了use mysql; 语句,想再次查询当前有哪些数据库,仍然是使用show databases;命令,如果想跳到其他数据库可以使用use test; 进行切换,其中test为你想要切换的数据库名。

推荐 《mysql视频教程》

在日常的网站维护和管理中,会用到非常多的SQL语句,熟练使用对网站管理有很多好处,尤其是站群管理的时候,以下为各位整理了命令行常用的MySQL命令,希望对各位有所帮助。

MySQL命令行下18个常用命令

show databases
show tables;
use mysql; grant all on *.* to root@'%' identified by '123' with grant option; commit;

3、修改密码

grant all on *.* to xing@'localhost' identified by '123456' with grant option; update user set password = password('newpwd') where user = 'xing' and host='localhost'; flush privileges;
create database testdb;
create database if not testdb;
use testdb; create table table1( username varchar(12), password varchar(20));
create table if not exists aaa(ss varchar(20));
describe table1;
insert into table1(username,password) values ('leizhimin','lavasoft'), ('hellokitty','hahhahah'); commit;

10、查询表table1:

select * from table1;
update table1 set password='hehe' where username='hellokitty'; commit;
delete from table1 where username='hellokitty'; commit;

13、给表添加一列:

alter table table1 add column(  sex varchar(2) comment '性别',  age date not null comment '年龄' ); commit;

14、修改表结构

从查询创建一个表table1:

create table tmp as select * from table1;

15、删除表table1:

drop table if exists table1; drop table if exists tmp;

16、备份数据库testdb

mysqldump -h 192.168.3.143 -u root -p pwd -x --default-character-set=gbk >C:\testdb.sql

17、删除数据库testdb

drop database testdb;
mysql -u root -pleizhimin testdb <C:\testdb.sql

以上就是重新查看当前有哪些数据库的详细内容,更多内容请关注技术你好其它相关文章!

来源链接:
免责声明:
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场
标签: 查看数据库
上一篇:php获取远程图片并下载保存到本地的方法分析 下一篇:inner join用法是什么

相关资讯