重新查看当前有哪些数据库
首先打开cmd,输入net start mysql启动mysql服务,然后输入mysql -hlocalhost -uroot -p回车登录数据库,之后就可以输入命令了。
MySQL命令行有很多命令,其中查看有哪些数据库,我们可以使用show databases;命令进行查看,注意分号不要忘了。
如果在此之前你使用了use mysql; 语句,想再次查询当前有哪些数据库,仍然是使用show databases;命令,如果想跳到其他数据库可以使用use test; 进行切换,其中test为你想要切换的数据库名。直线电机怎么样
在日常的网站维护和管理中,会用到非常多的SQL语句,熟练使用对网站管理有很多好处,尤其是站群管理的时候,以下为各位整理了命令行常用的MySQL命令,希望对各位有所帮助。
MySQL命令行下18个常用命令
1、显示数据库
1 |
|
显示表
1 |
|
2、创建用户
创建root用户密码为123
1 2 3 |
|
3、修改密码
1 2 3 |
|
4、创建数据库testdb:
1 |
|
5、预防性创建数据库:
1 |
|
6、创建表:
1 2 3 4 |
|
7、预防性创建表aaa:
1 |
|
8、查看表结构:
1 |
|
9、插入数据到表table1:
1 2 3 4 |
|
10、查询表table1:
1 |
|
11、更改数据:
1 2 |
|
12、删除数据:
1 2 |
|
13、给表添加一列:
1 2 3 4 5 |
|
14、修改表结构
从查询创建一个表table1:
1 2 |
|
15、删除表table1:
1 2 |
|
16、备份数据库testdb
1 |
|
17、删除数据库testdb
1 |
|
18、恢复testdb数据库
首先先建立testdb数据库,然后用下面命令进行本地恢复
1 |
|