導航:首頁 > 程序命令 > mysqldba命令

mysqldba命令

發布時間:2022-06-12 18:58:58

『壹』 高級mysql dba必備哪些技能

高級操作
1.Mysql 主從同步配置
2.Mysql 雙master 配置
3.Mysql 雙master+叢庫+keepalived 配置高可用資料庫
客戶端
作為DBA,一定不要用各種GUI工具,mysql自帶命令行client才是你的最佳武器
可選項
1.mysql 分區配置,因為限制太多,實際中分表都是程序做
2.高性能 mysql
a).drizzle
b).MariaDB
c).handlersocket

基本知識
1.mysql的編譯安裝
2.mysql 第3方存儲引擎安裝配置方法
3.mysql 主流存儲引擎(MyISAM/innodb/MEMORY)的特點
4.字元串編碼知識
5.MySQL用戶賬戶管理
6.數據備份/數據入導出
7.mysql 支持的基本數據類型
8.庫/表/欄位/索引 的創建/修改/刪除
9.基本sql 語法:select/insert/update/delete,掌握最基本的語法即可,什麼inner join,left join的了解就行 mysql的應用場景大多都是高並發訪問/業務邏輯簡單,join/子查詢/視圖/觸發器 基本上不用
10.sql 聚集查詢:group by/having
11.如何用explain 分析優化查詢
12.常見 sql 優化技巧
a).select xx from yyy limited ...,
b).order by random
c).select count(*) from
13.各種show xxx 指令,大概有20種,每個都嘗試用一次
14.show VARIABLES; 大概有240項,逐條看懂,可以列印出來貼牆上

『貳』 如何在windows裡面安裝MySQL

Windows上安裝MySQL


MySQL針對不同的用戶提供了2中不同的版本:

MySQL Community Server:社區版。由MySQL開源社區開發者和愛好者提供技術支持,對開發者開放源代碼並提供免費下載。

MySQL Enterprise Server:企業版。包括最全面的高級功能和管理工具,不過對用戶收費。

下面講到的MySQL安裝都是以免費開源的社區版為基礎。打開MySQL資料庫官網的下載地址http://dev.mysql.com/downloads/mysql,上面提供了兩種安裝文件,一種是直接安裝的MSI安裝文件,另一種是需要解壓並配置的壓縮包文件。我這里用的是5.7.10版本的安裝。

用MSI安裝包安裝

根據自己的操作系統下載對應的32位或64位安裝包。按如下步驟操作:
第一步:安裝許可
雙擊安裝文件,在如下圖所示界面中勾選「I accept the license terms」,點擊「next」。

經過以上步驟後MySQL伺服器安裝完成。

『叄』 15個 MySQL 基礎面試題,DBA 們准備好了嗎

問題1:你如何確定 MySQL 是否處於運行狀態?
答案: 在Debian 上運行命令 service mysql status,然後看輸出即可。
在 RedHat 或者 centos 上運行命令 service mysqld status,然後看看輸出即可。

問題2:如何開啟或停止 MySQL 服務?
答案:運行命令 service mysqld start 開啟服務;
運行命令 service mysqld stop 停止服務。

問題3:如何通過 Shell 登入 MySQL?
答案:運行命令 mysql -u用戶名 -p登陸密碼

問題4:如何列出所有資料庫?
答案:運行命令 show databases;

問題5: 如何切換到某個資料庫並在上面工作?
答案:(1)運行命令 use database_name;
(2)進入名為 database_name 的資料庫。

問題6:如何列出某個資料庫內所有表?
答案:在當前資料庫運行命令 show tables;

問題7:如何獲取表內所有 Field 對象的名稱和類型?
答案:運行命令 describe 表名;
簡寫為desc 表名;

問題8:如何刪除表?
答案:運行命令 drop table 表名;

問題9:如何刪除資料庫?
答案:運行命令 drop database 資料庫名;

問題10:如何查看錶內所有數據?
答案:運行命令 select * from 表名;

問題11:如何從表(比如 oc_users )中獲取一個 field 對象(比如 uid)的所有數據?
答案:運行命令 select uid from oc_users;

問題12:假設你有一個名為 『xyz』 的表,它存在多個欄位,如 『createtime』和 『engine』,
名為 engine 的欄位由 『Memoty』 和 『MyIsam』 兩種數值組成。
如何只列出 『createtime』 和 『engine』 這兩列,並且 engine 的值為 『MyIsam』?
答案:運行命令 select create_time, engine from xyz where engine = 「MyIsam」 ;

問題13:如何列出表 『xrt』 內 name 域值為 『tecmint』,web_address 域值為 『tecmint.com』 的所有數據?
答案:運行命令 select * from xrt where name = 「tecmint」 and web_address = 「tecmint.com」 ;

問題14:如何列出表 『xrt』 內 name 域值不為 『tecmint』,web_address 域值為 『tecmint.com』 的所有數據?
答案:運行命令 select * from xrt where name != 「tecmint」 and web_address = 「tecmint.com」;

問題15:如何知道表內行數?
答案:運行命令 select count(*) from 表名;

『肆』 dba的問題

學習dba不是一朝一夕的事情,我個人覺得:
以oracle+unix的模式來學習能讓你更好理解
那麼首先你需要學習一些基礎:
1、sql語言,這是基礎中的基礎
2、unix基本操作,安裝、配置unix、oracle
3、oracle存儲結構,oracle文件結構,oracle基礎配置
4、sql語句以及執行分析、資料庫調優等
5、適當的編程語言以及操作系統知識是需要的
6、堅持不懈

你可以到itpub上找到各個階段的非常翔實的教程以及資料和faq

『伍』 mysql 創建完索引之後 ,查詢反而變慢了,這是為什麼

我們先來看第一個階段,MySQL慢的診斷思路,一般我們會從三個方向來做:

『陸』 求助,MySql 5.6.17 授權用戶問題

慢慢看吧
mysql中可以給你一個用戶授予如select,insert,update,delete等其中的一個或者多個許可權,主要使用grant命令,用法格式為:
grant 許可權 on 資料庫對象 to 用戶
一、grant 普通數據用戶,查詢、插入、更新、刪除 資料庫中所有表數據的權利。
grant select on testdb.* to common_user@』%』
grant insert on testdb.* to common_user@』%』
grant update on testdb.* to common_user@』%』
grant delete on testdb.* to common_user@』%』
或者,用一條 mysql 命令來替代:
grant select, insert, update, delete on testdb.* to common_user@』%』

二、grant 資料庫開發人員,創建表、索引、視圖、存儲過程、函數。。。等許可權。
grant 創建、修改、刪除 mysql 數據表結構許可權。
grant create on testdb.* to developer@』192.168.0.%』;
grant alter on testdb.* to developer@』192.168.0.%』;
grant drop on testdb.* to developer@』192.168.0.%』;
grant 操作 mysql 外鍵許可權。
grant references on testdb.* to developer@』192.168.0.%』;
grant 操作 mysql 臨時表許可權。
grant create temporary tables on testdb.* to developer@』192.168.0.%』;
grant 操作 mysql 索引許可權。
grant index on testdb.* to developer@』192.168.0.%』;
grant 操作 mysql 視圖、查看視圖源代碼 許可權。
grant create view on testdb.* to developer@』192.168.0.%』;
grant show view on testdb.* to developer@』192.168.0.%』;
grant 操作 mysql 存儲過程、函數 許可權。
grant create routine on testdb.* to developer@』192.168.0.%』; - now, can show procere status
grant alter routine on testdb.* to developer@』192.168.0.%』; - now, you can drop a procere
grant execute on testdb.* to developer@』192.168.0.%』;

三、grant 普通 dba 管理某個 mysql 資料庫的許可權。
grant all privileges on testdb to dba@』localhost』
其中,關鍵字 「privileges」 可以省略。

四、grant 高級 dba 管理 mysql 中所有資料庫的許可權。
grant all on *.* to dba@』localhost』

五、mysql grant 許可權,分別可以作用在多個層次上。
1. grant 作用在整個 mysql 伺服器上:
grant select on *.* to dba@localhost; - dba 可以查詢 mysql 中所有資料庫中的表。
grant all on *.* to dba@localhost; - dba 可以管理 mysql 中的所有資料庫
2. grant 作用在單個資料庫上:
grant select on testdb.* to dba@localhost; - dba 可以查詢 testdb 中的表。
3. grant 作用在單個數據表上:
grant select, insert, update, delete on testdb.orders to dba@localhost;
4. grant 作用在表中的列上:
grant select(id, se, rank) on testdb.apache_log to dba@localhost;
5. grant 作用在存儲過程、函數上:
grant execute on procere testdb.pr_add to 』dba』@』localhost』
grant execute on function testdb.fn_add to 』dba』@』localhost』

六、查看 mysql 用戶許可權
查看當前用戶(自己)許可權:
show grants;
查看其他 mysql 用戶許可權:
show grants for dba@localhost;

七、撤銷已經賦予給 mysql 用戶許可權的許可權。
revoke 跟 grant 的語法差不多,只需要把關鍵字 「to」 換成 「from」 即可:
grant all on *.* to dba@localhost;
revoke all on *.* from dba@localhost;

八、mysql grant、revoke 用戶許可權注意事項
1. grant, revoke 用戶許可權後,該用戶只有重新連接 mysql 資料庫,許可權才能生效。
2. 如果想讓授權的用戶,也可以將這些許可權 grant 給其他用戶,需要選項 「grant option「
grant select on testdb.* to dba@localhost with grant option;
這個特性一般用不到。實際中,資料庫許可權最好由 dba 來統一管理。

注意:修改完許可權以後 一定要刷新服務,或者重啟服務

『柒』 請教大家,MySQL安裝版與解壓版的區別

本文針對mysql-noinstall版本,也就是解壓縮版的安裝配置應用做了個總結,這些操作都是平時很常用的操作。文章中不對mysql的可執行文件安裝版做介紹了,可執行安裝版有很多的弊端,我也不一一說了。總之,我喜歡綠色環保的,包括eclipse、tomcat、jboss、apache也是,即使操作系統重裝了,這些軟體也不需要重裝,可謂一勞永逸!

環境:
Windows 2000/XP/2003
mysql-noinstall-5.0.37-win32.zip

一、下載MySQL

http://www.mysql.com/downloads

二、安裝過程

1、解壓縮mysql-noinstall-5.0.37-win32.zip到一個目錄,加入解壓縮到E:\myserver目錄。

2、編寫mysql的運行配置文件my.ini
my.ini
-----------------------------
[WinMySQLAdmin]
# 指定mysql服務啟動啟動的文件
Server=E:\\myserver\\mysql-5.0.37-win32\\bin\\mysqld-nt.exe

[mysqld]
# 設置mysql的安裝目錄
basedir=E:\\myserver\\mysql-5.0.37-win32
# 設置mysql資料庫的數據的存放目錄,必須是data,或者是\\xxx\data
datadir=E:\\myserver\\mysql-5.0.37-win32\\data
# 設置mysql伺服器的字元集
default-character-set=gbk

[client]
# 設置mysql客戶端的字元集
default-character-set=gbk
-----------------------------

3、安裝mysql服務
從MS-DOS窗口進入目錄E:\myserver\mysql-5.0.37-win32\bin,運行如下命令:
mysqld --install mysql5 --defaults-file= E:\myserver\mysql-5.0.37-win32\my.ini

4、啟動mysql資料庫
還在上面的命令窗口裡面,輸入命令:net start mysql5
這樣就啟動了mysql服務。

5、(本地)登錄mysql資料庫
還在上面的命令窗口裡面,輸入命令:mysql -u root -p
回車後提示輸入密碼。
mysql解壓縮版初次安裝管理員root的密碼為空,因此直接再回車一次就登入mysql資料庫了。

如果你不是初次登錄mysql,你還擁有網路地址的用戶,那麼你可以用如下命令登錄到mysql伺服器,這個mysql伺服器也許在遠方,也許在本地。這種登錄方式叫「遠程登錄」,命令如下:
mysql -h 192.168.3.143 -u root -p
mysql -h 192.168.3.143 -u root -pleimin

-h是指定登錄ip,-u指定用戶,-p指定密碼,-p後如果什麼都不寫,那麼接下來會提示輸入密碼,-p後也可以直接寫上密碼,這樣就不再需要輸入密碼了。

6、操作資料庫和表
登錄mysql資料庫後,就可以執行指定操作資料庫,用命令:use 資料庫名
指定了操作的資料庫對象後,就可以操作資料庫中的表了,操作方法當然是SQL命令了,呵呵。

7、更改mysql資料庫管理員root的密碼
mysql資料庫中默認有個mysql資料庫,這個是mysql系統的資料庫,用來保存資料庫用戶、許可權等等很多信息。要更改密碼,就要操作mysql資料庫的user表。

現在mysql的root用戶密碼還為空,很不安全的,假設要更改密碼為「leimin」。

還在上面的命令窗口裡面,執行如下命令:
use mysql;
grant all on *.* to root@'%' identified by 'leimin' with grant option;
commit;

這段命令的含義是,添加一個root用戶,擁有所有的許可權,密碼為「leimin」,並且這個用戶不但可以本地訪問,也可以通過網路訪問。強調這個原因是mysql系統自帶的的那個root用戶只能從本地訪問,它@字元後面的標識是localhost。具體可以查看mysql數據的uer表看看,這樣以來,就有兩個root用戶了,一個是系統原來的,一個新建的,為了管理的方便,就將mysql自帶root刪除,保留剛創建的這個root用戶,原因是這個用戶可以通過網路訪問mysql。

然後,刪除用戶的命令:
user mysql;
delete from user where user='root' and host='localhost';
commit;

其實上面的方法是授權命令,在授權的同時創建了資料庫用戶。mysql也有單獨的修改用戶密碼的方法,下面看看如何操作。
首先,先建立一個用戶lavasoft,密碼為:123456
grant all on *.* to lavasoft@'localhost' identified by '123456' with grant option;

接下來就修改這個用戶的密碼為:leimin
update user set password = password('leimin') where user = 'lavasoft' and host='localhost';
flush privileges;

說明一點,最好用grant的方式創建mysql用戶,尤其對mysql DBA來說,創建用戶的同時要指定用戶許可權,養成好習慣很重要的。

這個修改方法實際上用的是mysql函數來進行的,還有更多的方法,我就不一一介紹了。
還要注意一點就是在修改密碼等操作的時候,mysql不允許為表指定別名,但是初次在外卻沒有這個限制。

8、創建資料庫
實際上mysql資料庫中除了mysql資料庫外,還有一個空的資料庫test,供用戶測試使用。
現在繼續創建一個資料庫testdb,並執行一系列sql語句看看mysql資料庫的基本操作。

創建資料庫testdb:
create database testdb;

預防性創建資料庫:
create database if not testdb

創建表:
use testdb;
create table table1(
username varchar(12),
password varchar(20));

預防性創建表aaa:
create table if not exists aaa(ss varchar(20));

查看錶結構:
describe table1;

插入數據到表table1:
insert into table1(username,password) values
('leimin','lavasoft'),
('hellokitty','hahhahah');
commit;

查詢表table1:
select * from table1;

更改數據:

update table1 set password='hehe' where username='hellokitty';
commit;

刪除數據:
delete from table1 where username='hellokitty';
commit;

給表添加一列:
alter table table1 add column(
sex varchar(2) comment '性別',
age date not null comment '年齡'
);
commit;

從查詢創建一個表table1:
create table tmp as
select * from table1;

刪除表table1:
drop table if exists table1;
drop table if exists tmp;

9、備份資料庫testdb
mysqlmp -h 192.168.3.143 -u root -pleimin -x --default-character-set=gbk >C:\testdb.sql

10、刪除資料庫testdb
drop database testdb;

11、恢復testdb資料庫
首先先建立testdb資料庫,然後用下面命令進行本地恢復:
mysql -u root -pleimin testdb <C:\testdb.sql

12、刪除mysql服務
假如你厭倦mysql了,你需要卸載,那麼你只需要這么做

停止mysql服務
net stop mysql5

刪除mysql服務
sc delete mysql5

然後刪除msyql的安裝文件夾,不留任何痕跡。

『捌』 MySQL:grant 語法詳解(MySQL5.X)

本文實例,運行於MySQL5.0
及以上版本。
MySQL
賦予用戶許可權命令的簡單格式可概括為:
grant
許可權on
資料庫對象to
用戶
一、grant
普通數據用戶,查詢、插入、更新、刪除資料庫中所有表數據的權利。
grant
select
on
testdb.*
to
common_user@'%'
grant
insert
on
testdb.*
to
common_user@'%'
grant
update
on
testdb.*
to
common_user@'%'
grant
delete
on
testdb.*
to
common_user@'%'
或者,用一條MySQL
命令來替代:
grant
select,
insert,
update,
delete
on
testdb.*
to
common_user@'%'
二、grant
資料庫開發人員,創建表、索引、視圖、存儲過程、函數。。。等許可權。
grant
創建、修改、刪除MySQL
數據表結構許可權。
grant
create
on
testdb.*
to
developer@'192.168.0.%';
grant
alter
on
testdb.*
to
developer@'192.168.0.%';
grant
drop
on
testdb.*
to
developer@'192.168.0.%';
grant
操作MySQL
外鍵許可權。
grant
references
on
testdb.*
to
developer@'192.168.0.%';
grant
操作MySQL
臨時表許可權。
grant
create
temporary
tables
on
testdb.*
to
developer@'192.168.0.%';
grant
操作MySQL
索引許可權。
grant
index
on
testdb.*
to
developer@'192.168.0.%';
grant
操作MySQL
視圖、查看視圖源代碼許可權。
grant
create
view
on
testdb.*
to
developer@'192.168.0.%';
grant
show
view
on
testdb.*
to
developer@'192.168.0.%';
grant
操作MySQL
存儲過程、函數許可權。
grant
create
routine
on
testdb.*
to
developer@'192.168.0.%';
--
now,
can
show
procere
status
grant
alter
routine
on
testdb.*
to
developer@'192.168.0.%';
--
now,
you
can
drop
a
procere
grant
execute
on
testdb.*
to
developer@'192.168.0.%';
三、grant
普通DBA
管理某個MySQL
資料庫的許可權。
grant
all
privileges
on
testdb
to
dba@'localhost'
其中,關鍵字“privileges”
可以省略。
四、grant
高級DBA
管理MySQL
中所有資料庫的許可權。
grant
all
on
*.*
to
dba@'localhost'
五、MySQLgrant
許可權,分別可以作用在多個層次上。
1.
grant
作用在整個MySQL
伺服器上:
grant
select
on
*.*
to
dba@localhost;
--
dba
可以查詢MySQL
中所有資料庫中的表。
grant
all
on
*.*
to
dba@localhost;
--
dba
可以管理MySQL
中的所有資料庫
2.
grant
作用在單個資料庫上:
grant
select
on
testdb.*
to
dba@localhost;
--
dba
可以查詢testdb
中的表。
3.
grant
作用在單個數據表上:
grant
select,
insert,
update,
delete
on
testdb.orders
to
dba@localhost;
4.
grant
作用在表中的列上:
grant
select(id,
se,
rank)
on
testdb.apache_log
to
dba@localhost;
5.
grant
作用在存儲過程、函數上:
grant
execute
on
procere
testdb.pr_add
to
'dba'@'localhost'
grant
execute
on
function
testdb.fn_add
to
'dba'@'localhost'
六、查看MySQL
用戶許可權
查看當前用戶(自己)許可權:
show
grants;
查看其他MySQL
用戶許可權:
show
grants
for
dba@localhost;
七、撤銷已經賦予給MySQL
用戶許可權的許可權。
revoke
跟grant
的語法差不多,只需要把關鍵字“to”
換成“from”
即可:
grant
all
on
*.*
to
dba@localhost;
revoke
all
on
*.*
from
dba@localhost;
八、MySQLgrant、revoke
用戶許可權注意事項
1.
grant,
revoke
用戶許可權後,該用戶只有重新連接MySQL
資料庫,許可權才能生效。
2.
如果想讓授權的用戶,也可以將這些許可權grant
給其他用戶,需要選項“grant
option“
grant
select
on
testdb.*
to
dba@localhost
with
grant
option;

這個特性一般用不到。實際中,資料庫許可權最好由DBA
來統一管理。

『玖』 成為互聯網公司mysql DBA需要掌握哪些技能

高級操作
1.Mysql 主從同步配置
2.Mysql 雙master 配置
3.Mysql 雙master+叢庫+keepalived 配置高可用資料庫
客戶端
作為DBA,一定不要用各種GUI工具,mysql自帶命令行client才是你的最佳武器
可選項
1.mysql 分區配置,因為限制太多,實際中分表都是程序做
2.高性能 mysql
a).drizzle
b).MariaDB
c).handlersocket

基本知識
1.mysql的編譯安裝
2.mysql 第3方存儲引擎安裝配置方法
3.mysql 主流存儲引擎(MyISAM/innodb/MEMORY)的特點
4.字元串編碼知識
5.MySQL用戶賬戶管理
6.數據備份/數據入導出
7.mysql 支持的基本數據類型
8.庫/表/欄位/索引 的創建/修改/刪除
9.基本sql 語法:select/insert/update/delete,掌握最基本的語法即可,什麼inner join,left join的了解就行 mysql的應用場景大多都是高並發訪問/業務邏輯簡單,join/子查詢/視圖/觸發器 基本上不用

『拾』 如何利用mysql系統命令直接查詢某欄位出現在所在的表方法

MYSQL沒有類似於MSSQLSERVER的sysobjects或者Oracle的dba_tab_comments這樣的表,但MYSQL可以用SHOW命令查詢資料庫和表、欄位、索引等信息:

一些SHOW語句提供額外的字元集信息。這些語句包括SHOW CHARACTER SET、SHOW COLLATION、SHOW CREATE DATABASE、SHOW CREATE TABLE和SHOW COLUMNS。

SHOW CHARACTER SET命令顯示全部可用的字元集。它帶有一個可選的LIKE子句來指示匹配哪些字元集名。

閱讀全文

與mysqldba命令相關的資料

熱點內容
安卓手機android文件夾能刪嗎 瀏覽:340
交流電壓有效值單片機 瀏覽:228
python得到數組長度 瀏覽:182
哪個app教煮飯 瀏覽:1000
買周邊的app叫什麼 瀏覽:156
安卓機怎麼安裝雲頂之弈 瀏覽:999
微信錢包鎖加密 瀏覽:200
電腦作為伺服器的地址嗎 瀏覽:510
11選5app怎麼注冊不了 瀏覽:370
php工程師是什麼意思 瀏覽:727
明日方舟啟動器怎麼換伺服器 瀏覽:485
1核2g的伺服器能做什麼騰訊雲 瀏覽:741
怎麼才能ipad和安卓手機同時登qq 瀏覽:945
國際服安卓手機登不進去怎麼辦 瀏覽:390
兄弟列印機編程 瀏覽:160
單片機改12t模式 瀏覽:909
abb機器人編程教材視頻 瀏覽:931
skins的梯度壓縮衣 瀏覽:981
電腦進入桌面文件夾就黑屏 瀏覽:949
新預演算法推進 瀏覽:509