mysql--串連、常用命令

來源:互聯網
上載者:User

標籤:查詢   innodb   int   效果   刪除   資料庫版本   tab   variables   shel   

*********串連

mysql -uroot -p123456                                      #預設會使用sock連接埠登入

mysql -uroot -p123456  -h127.0.0.1 -P3306     #使用ip+3306連接埠登入,遠程

mysql -uroot -p123456 -S/tmp/mysql.sock      #使用監聽的sock;適合本機

mysql -uroot -p123456 -e "show databases"   #使用在shell指令碼裡面

 

*********常用命令

一:

mysql 常用的命令:

查詢庫 show databases;切換庫 use mysql;查看庫裡的表 show tables;查看錶裡的欄位 desc tb_name;查看建表語句 show create table tb_name\G;查看目前使用者  select user();查看當前使用的資料庫  select database()*****************************************************************desc user;  查看一個表裡欄位有哪些show create table user\G;  加上G是比較有順序,整潔一點;select * from user\G; 加上G,效果同上;*****************************************************************查看mysql的命令曆史:ls -al     #會看到有個檔案為 .mysql_historyless  .mysql_history*****************************************************************use mysql;select database()  #查看當前使用的資料庫*****************************************************************二:建立庫 create database db1;建立表 use db1;create table t1(‘id‘ int(4), ‘name‘ char(40) );查看當前資料庫版本 select version();查看資料庫狀態 show status;查看各參數  show variables;show variables like ‘max_connect%‘;修改參數 set global max_connect_errors=1000;查看隊列 show processlist;  show full processlist;  建立庫,create database db1;show databases;use db1;create table t1(‘id‘ int(4), ‘name‘ char(40) );show create table t1\G;drop table t1;刪除此表create table t1(‘id‘ int(4), ‘name‘ char(40) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;show create table t1\G;   會看到charset 變成utf8;select version();show status;show variables;show variables like ‘max_connect%‘;或者查看 show variable like ‘sock%‘;set global max_connect_errors=1000;show variables like ‘max_connect%‘;這個修改為1000的數值,如果需要重啟也生效的話,就需要去修改my.cnf檔案;*****************************************************************show processlist; show full processlist; #此命令令可以查看:1.看看你的mysql在幹啥?2.哪些使用者在串連?3.串連的時候在幹啥,有沒有鎖表;

mysql--串連、常用命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.