CentOS 6 使用 mycli

  1. 執行 mycli 以 root 帳號登入 mysql,出現無法連線 mysql server 的錯誤訊息,但還是可以下命令。
    [root@kvm6 ~]# mycli -uroot -p123qwe mysql
    (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
    mysql 5.5.49
    mycli 1.19.0
    Chat: https://gitter.im/dbcli/mycli
    Mail: https://groups.google.com/forum/#!forum/mycli-users
    Home: http://mycli.net
    Thanks to the contributor - ushuz
    mysql root@localhost:mysql> exit                                                  
    Goodbye!
    
  2. mycli 下命令時使用 -S 選項指定 mysql socket 檔就不會再出現錯誤訊息。
    [root@kvm6 ~]# mycli -uroot -S /var/lib/mysql/mysql.sock -p123qwe mysql
    mysql 5.5.49
    mycli 1.19.0
    Chat: https://gitter.im/dbcli/mycli
    Mail: https://groups.google.com/forum/#!forum/mycli-users
    Home: http://mycli.net
    Thanks to the contributor - Darik Gamble
    mysql root@localhost:mysql>
    
  3. 下命令 show 加空白就會出現提示視窗,列出可以接的參數供您選擇,不用再把完整命令打完。
    mysql root@localhost:mysql> show AUTHORS 
                                      AUTHORS           
                                      BINARY LOGS       
                                      BINLOG EVENTS     
                                      CHARACTER SET     
                                      COLLATION         
                                      COLUMNS
    
  4. 選擇 databases 後執行。
    mysql root@localhost:mysql> show  DATABASES; 
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    +--------------------+
    3 rows in set
    Time: 0.024s
    mysql root@localhost:mysql> exit                                                  
    Goodbye!
    
                                                                                                                    
     [F3] Multiline: OFF    Right-arrow to complete suggestion