mysql prompt一个特别好用的命令

    登录数据库后,选择数据库时发现以下提示,

想必大家在命令行操作mysql的时候会十分发愁现在的操作的是那个数据库吧,至少我就纠结过,可能您会说我打一条命令不就知道了,是的这样做确实可以的。
可是今儿给大家介绍个好用的命令–prompt

mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

复制代码 代码如下:

Database changed
mysql>

[root@fsailing1 ~]# mysql -uroot -p –prompt=”\u@\h:\d
\r:\m:\s>”
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 378
Server version: 5.0.95 Source distribution

    意思是
预读这个库中表以及表列信息,一般原因是当库中表很多,表中数据很大时,就会出现执行use
<库名>后半天没反应,连接很慢的情况,解决办法就是 -A
方式登录数据库,不会预读库中表信息。

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights
reserved.

shell> mysql -h hostname -u username -P port -p -A

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Enter password:

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input
statement.

(eg:shell> mysql -h 127.0.0.1 -u root -P 3306 -p -A)

root@localhost:(none) 08:23:32>use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

本机登录数据库,直接执行-A也是可以的。

Database changed
root@localhost:test 08:23:44>exit;

mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

这样做的好处就是让我们大家在操作数据库时更加方便快捷。

Database changed
mysql> q
Bye
[root@localhost ~]# mysql -u root -p
-A
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 12
Server version: 5.7.23 MySQL Community Server (GPL)

您也可以在在my.cnf配置文件里进行配置:

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights
reserved.

复制代码 代码如下:

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*
*
Website