MySQL常用命令操作

來源:互聯網
上載者:User

標籤:多個   mail   使用   soc   lte   select   連接埠   style   串連   

1. 命令列登入使用預設3306連接埠的MySQL:

  mysql -u root -p

2. 通過TCP串連管理不同連接埠的多個MySQL(注意:MySQL4.1以上版本才有此項功能):

  mysql -u root -p --protocol=tcp --host=localhost --port=3307

3. 通過socket通訊端管理不同連接埠的多個MySQL:

  mysql -u root -p --socket=/tmp/mysql3307.sock

4. 通過連接埠和IP管理不同連接埠的多個MySQL:

  mysql -u root -p -P 3306 -h 127.0.0.1

5. 修複損壞的表(本例中要修複的表為t_user):

  repair table t_user;

6. MySQL將 root 的密碼改為 sa123:

  mysqladmin -u root -p 123 password sa123

7. 增加一個使用者 test1 密碼為abc,讓他可以在任何主機上登入,並對所有資料庫有查詢、插入、修改、刪除的許可權。

  首先用root使用者連入MYSQL,然後鍵入以下命令:

  grant select,insert,update,delete on *.* to [[email protected]”%][email protected]”%[/email]” Identified by “abc”;

8. 從第0行開始取,取3行:

  select * from student limit 0,3;

9. 查看當前資料庫編碼:

  show variables like ‘character_set_database‘;

10. 修改資料庫編碼(xxx是資料庫名):

  alter database xxx CHARACTER SET utf8;

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.