MySQL語法常用大全 自己整理的學習筆記

2021-06-22 18:37:48 字數 1315 閱讀 5050

select * from emp; #注釋

#---------------------------

#----命令列連線mysql---------

#啟動mysql伺服器

net start mysql

#關閉 

net stop mysql 

#進入mysql -h 主機位址 -u 使用者名稱 -p 使用者密碼

#退出exit

#---------------------------

#----mysql使用者管理---------

#修改密碼:首先在dos 下進入mysql安裝路徑的bin目錄下,然後鍵入以下命令:

mysqladmin -uroot -p123 password 456;

#增加使用者

#格式:grant 許可權 on 資料庫.* to 使用者名稱@登入主機 identified by '密碼'

/*如,增加乙個使用者user1密碼為password1,讓其可以在本機上登入, 並對所有資料庫有查詢、插入、修改、刪除的許可權。首先用以root使用者連入mysql,然後鍵入以下命令: 

grant select,insert,update,delete on *.* to user1@localhost identified by "password1"; 

如果希望該使用者能夠在任何機器上登陸mysql,則將localhost改為"%"。 

如果你不想user1有密碼,可以再打乙個命令將密碼去掉。 

grant select,insert,update,delete on mydb.* to user1@localhost identified by ""; 

*/grant all privileges on wpj1105.* to 

sunxiao@localhost

identified by '123'; #all privileges 所有許可權

#----------------------------

#-----mysql資料庫操作基礎-----

#顯示資料庫

show databases;

#判斷是否存在資料庫wpj1105,有的話先刪除

drop database if exists wpj1105;

#建立資料庫

create database wpj1105;

#刪除資料庫

drop database wpj1105;

#使用該資料庫

use wpj1105;

#顯示資料庫中的表

show tables;

#先判斷表是否存在,存在先刪除

mysql 基本語法整理大全

mysql 語法整理 使用myblog資料庫 use myblog 顯示表 show tables 增加 insert into users username,password realname values zhangsan 123 張三 查詢所有資訊 select from users 查詢所有...

mysql語法大全

1.ubuntu啟動mysql伺服器 sudo service mysql start 需要root許可權 2.ubuntu停止mysql伺服器 sudo service mysql stop 需要root許可權 3.進入mysql mysql h 主機位址 p 主機port u 使用者名稱 p 使...

MySQL所有常用語法大全

一 常用運算元據庫的命令 1.show databases 檢視所有的資料庫 2.create database test 建立乙個叫test的資料庫 3.drop database test 刪除乙個叫test的資料庫 4.use test 選中庫 在建表之前必須要選擇資料庫 5.show tab...