next up previous contents
Next: 實機操作練習題 Up: MyCLI Previous: mycli 命令   Contents   DYWANG_HOME

使用 mycli

  1. 執行 mycli 以 root 帳號登入 mysql,出現無法連線 mysql server 的錯誤訊息,但還是可以下命令。
    [root@kvm8 ~]# mycli -uroot -p123qwe
    (2003, "Can't connect to MySQL server on 'localhost' ([Errno 2] No such file or directory)")
    Failed to connect by socket, retrying over TCP/IP
    mariadb 10.3.11-MariaDB
    mycli 1.20.1
    Chat: https://gitter.im/dbcli/mycli
    Mail: https://groups.google.com/forum/#!forum/mycli-users
    Home: http://mycli.net
    Thanks to the contributor - QiaoHou Peng
    mariadb root@localhost:(none)> quit 
                                     quit   
                                                                                    
     [F3] Multiline: OFF    Right-arrow to complete suggestion
    
  2. mycli 下命令時使用 -S 選項指定 mysql socket 檔就不會再出現錯誤訊息。
    [root@kvm8 ~]# mycli -S /var/lib/mysql/mysql.sock -uroot -p123qwe
    mariadb 10.3.11-MariaDB
    mycli 1.20.1
    Chat: https://gitter.im/dbcli/mycli
    Mail: https://groups.google.com/forum/#!forum/mycli-users
    Home: http://mycli.net
    Thanks to the contributor - Whitane Tech
    mariadb root@localhost:(none)>
    
  3. 下命令 show 加空白就會出現提示視窗,列出可以接的參數供您選擇,不用再把完整命令打完。
    mariadb root@localhost:(none)> show  
                                         AUTHORS           
                                         BINARY LOGS       
                                         BINLOG EVENTS     
                                         CHARACTER SET     
                                         COLLATION         
                                         COLUMNS           
                                         CONTRIBUTORS                               
     [F3] Multiline: OFF    Right-arrow to complete suggestion
    
  4. 選擇 databases 後執行。
    mariadb root@localhost:(none)> show DATABASES;                                  
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    +--------------------+
    3 rows in set
    Time: 0.021s
    mariadb root@localhost:(none)>  
                                                                                                                    
     [F3] Multiline: OFF    Right-arrow to complete suggestion
    



De-Yu Wang 2020-04-07