天天看點

MySQL資料庫運維必會的100道面試題之(一)

1.寮€鍚疢ySQL鏈嶅姟

聽 聽 聽/etc/init.d/mysqld start

service mysqld start

systemctl 聽start mysqld聽

2.妫€娴嬬鍙f槸鍚﹁繍琛?

聽 聽 聽lsof -i :3306

netstat -lntup |grep 3306

MySQL資料庫運維必會的100道面試題之(一)

3.涓篗ySQL璁劇疆瀵嗙爜鎴栬€呬慨鏀瑰瘑鐮?

璁劇疆瀵嗙爜

聽 聽 聽mysql -uroot -ppassword -e "set passowrd for root = passowrd('passowrd')"

mysqladmin -uroot passowrd "NEWPASSWORD"

鏇存敼瀵嗙爜

聽 聽 聽mysqladmin -uroot passowrd oldpassowrd "NEWPASSWORD"

聽 聽 聽use mysql;

聽 聽 聽update user set passowrd = PASSWORD('newpassword') where user = 'root';flush privileges;

聽 聽 聽msyql 5.7浠ヤ笂鐗堟湰淇敼榛樿瀵嗙爜鍛戒護 聽

alter user 'root'@'localhost' identified by 'root'聽聽

4.鐧婚檰MySQL鏁版嵁搴撱€?

聽 聽 聽mysql -uroot -ppassword聽

5.鏌ョ湅褰撳墠鏁版嵁搴撶殑瀛楃闆?

聽 聽 聽show create database DB_NAME;

6.鏌ョ湅褰撳墠鏁版嵁搴撶増鏈?

聽 聽 聽mysql -V

聽 聽 聽mysql -uroot -ppassowrd -e "use mysql;select version();"

MySQL資料庫運維必會的100道面試題之(一)

7.鏌ョ湅褰撳墠鐧誨綍鐨勭敤鎴楓€?

聽 聽 聽select user();

MySQL資料庫運維必會的100道面試題之(一)

8.鍒涘緩GBK瀛楃闆嗙殑鏁版嵁搴搈ingongge锛屽苟鏌ョ湅宸插緩搴撳畬鏁磋鍙?

聽 聽 聽create database mingongge DEFAULT CHARSET GBK COLLATE gbk_chinese_ci;

9.鍒涘緩鐢ㄦ埛mingongge锛屼嬌涔嬪彲浠ョ鐞嗘暟鎹簱mingongge

聽 聽 聽grant all on mingongge.* to 'mingongge'@'localhost' identified by 'mingongge';

10.鏌ョ湅鍒涘緩鐨勭敤鎴穖ingongge鎷ユ湁鍝簺鏉冮檺

聽 聽 聽show grants for [email聽protected]

MySQL資料庫運維必會的100道面試題之(一)

11.鏌ョ湅褰撳墠鏁版嵁搴撻噷鏈夊摢浜涚敤鎴?

聽 聽 聽select user from mysql.user;

12.杩涘叆mingongge鏁版嵁搴?

聽 聽 聽use mingongge

MySQL資料庫運維必會的100道面試題之(一)

13.鍒涘緩涓€innodb GBK琛╰est锛屽瓧娈礽d int(4)鍜宯ame varchar(16)

聽 聽 聽create table test (

id int(4),

name varchar(16)

)ENGINE=innodb DEFAULT CHARSET=gbk;

14.鏌ョ湅寤鴻〃缁撴瀯鍙婅〃缁撴瀯鐨凷QL璇彞

聽 聽 聽desc test;

show create table test\G

MySQL資料庫運維必會的100道面試題之(一)

15.鎻掑叆涓€鏉℃暟鎹€?,mingongge鈥?

聽 聽 聽insert into test values('1','mingongge');

16.鍐嶆壒閲忔彃鍏?琛屾暟鎹?鈥?,姘戝伐鍝モ€濓紝鈥?,mingonggeedu鈥?

聽 聽 聽insert into test values('2','姘戝伐鍝?),('3','mingonggeedu');

MySQL資料庫運維必會的100道面試題之(一)

17.鏌ヨ鍚嶅瓧涓簃ingongge鐨勮褰?

聽 聽 select * from test where name = 'mingongge';

18.鎶婃暟鎹甶d绛変簬1鐨勫悕瀛梞ingongge鏇存敼涓簃gg

聽 聽 update test set name = 'mgg' where id = '1';

19.鍦ㄥ瓧娈祅ame鍓嶆彃鍏ge瀛楁锛岀被鍨媡inyint(2)

聽 聽 alter table test add age tinyint(2) after id;

MySQL資料庫運維必會的100道面試題之(一)

20.涓嶉€€鍑烘暟鎹簱,瀹屾垚澶囦喚mingongge鏁版嵁搴?

聽 聽 聽system mysqldump -uroot -pMgg123.0. -B mingongge >/root/mingongge_bak.sql

MySQL資料庫運維必會的100道面試題之(一)

聽鏇翠粠绮懼僵鍐呭 璇鋒寔缁叧娉ㄦ湰鍗氬鎴栨壂鐮佸叧娉ㄦ皯宸ュ摜涓漢鍏紬鍙?

MySQL資料庫運維必會的100道面試題之(一)

杞澆浜?https://blog.51cto.com/mingongge/1961093