重新查看当前有哪些数据库
首先打开cmd,输入net start mysql启动mysql服务,然后输入mysql -hlocalhost -uroot -p回车登录数据库,之后就可以输入命令了。
MySQL命令行有很多命令,其中查看有哪些数据库,我们可以使用show databases;命令进行查看,注意分号不要忘了。
如果在此之前你使用了use mysql; 语句,想再次查询当前有哪些数据库,仍然是使用show databases;命令,如果想跳到其他数据库可以使用use test; 进行切换,其中test为你想要切换的数据库名。
推荐 《mysql视频教程》
在日常的网站维护和管理中,会用到非常多的SQL语句,熟练使用对网站管理有很多好处,尤其是站群管理的时候,以下为各位整理了命令行常用的MySQL命令,希望对各位有所帮助。
MySQL命令行下18个常用命令
1、显示数据库
show databases
显示表
show tables;
2、创建用户
创建root用户密码为123
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;
4、创建数据库testdb:
create database testdb;
5、预防性创建数据库:
create database if not testdb;
6、创建表:
use testdb; create table table1( username varchar(12), password varchar(20));
7、预防性创建表aaa:
create table if not exists aaa(ss varchar(20));
8、查看表结构:
describe table1;
9、插入数据到表table1:
insert into table1(username,password) values ('leizhimin','lavasoft'), ('hellokitty','hahhahah'); commit;
10、查询表table1:
select * from table1;
11、更改数据:
update table1 set password='hehe' where username='hellokitty'; commit;
12、删除数据:
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;
18、恢复testdb数据库
首先先建立testdb数据库,然后用下面命令进行本地恢复
mysql -u root -pleizhimin testdb <C:\testdb.sql
以上是重新查看当前有哪些数据库的详细内容。更多信息请关注PHP中文网其他相关文章!

本文讨论了通过密码管理,使用远程访问,使用加密和常规更新来确保MySQL服务器免于未经授权的访问。它还涵盖监视和检测可疑活动以提高安全性。

本文讨论了使用角色有效管理用户权限,详细介绍角色定义,权限分配和动态调整。它强调了基于角色的访问控制以及角色如何简化用户管理ACR的最佳实践

文章讨论了MySQL特权:全局,数据库,表,列,例程和代理用户类型。它解释了授予,撤销特权和安全管理的最佳实践。突出了过度的风险。

本文解释了SQL中赠款语句的使用来分配各种特权,例如选择,插入和更新到用户或特定数据库对象上的角色。它还涵盖了通过撤销声明并授予特权的撤销特权

本文讨论了从其他存储过程或功能中调用存储过程,重点是SQL Server。它涵盖语法,诸如模块化和安全性,错误处理以及嵌套过程的设计注意事项。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

Atom编辑器mac版下载
最流行的的开源编辑器

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

禅工作室 13.0.1
功能强大的PHP集成开发环境

WebStorm Mac版
好用的JavaScript开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)