搜尋
首頁每日程式設計mysql知識重新查看目前有哪些資料庫

重新查看目前有哪些資料庫

重新查看目前有哪些資料庫

先開啟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中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

EditPlus 中文破解版

EditPlus 中文破解版

體積小,語法高亮,不支援程式碼提示功能

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具