登录

  • mysql -h [hostname] -u [username] -p  回车,输入密码
  • mysql -h [hostname] -u [username] -p[passward]  会暴露密码在界面上
  • 以上命令后跟 -A,能解决登录mysql后切换数据库时出现的以下问题

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

通过mysql --help查看下这个参数的含义:

  -A, --no-auto-rehash 
                      No automatic rehashing. One has to use 'rehash' to get
                      table and field completion. This gives a quicker start of
                      mysql and disables rehashing on reconnect. 

总结,出现问题的原因是: 我们进入mysql 时,没有使用-A参数; 当我们打开数据库,即use dbname时,要预读数据库信息,当使用-A参数时,就不预读数据库信息,也能提高连接库的速度

退出

  • 退出当前命令行:\c
  • 退出 mysql 命令行:\q 或 exit 或 quit

更多推荐

mysql登录/退出命令