mysql使用小tip
小tip1
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
当切换到某个库时,经常会出现上面信息,意思是预读这个库中表以及表列信息。
但是当库中表很多,表中数据很大时,就会出现执行use <库名>后半天没反应,连接很慢的情况
上面其实已经有提示了(You can turn off this feature to get a quicker startup with -A)
就是在登陆连接mysql时使用-A参数,这样就不会预读库中表信息了,能提高连接库的速度.
shell> mysql -h hostname -u username -P port -p -A
Enter password:
MySQL -A参数含义:
shell> 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.
小tip2
如何使用 MySQL 命令来查看变量。
1. 使用 SHOW 命令查看变量
SHOW VARIABLES;
执行以上命令后,会显示出 MySQL 中所有的变量及其对应的值。如果只想查看特定的变量,可以在命令后跟上变量名。
SHOW VARIABLES LIKE 'max_connections';
执行以上命令后,会显示出 max_connections 变量及其对应的值。
2. 使用 SELECT 命令查看变量
SELECT @@max_connections;
执行以上命令后,会显示出 max_connections 变量的值。
不同于 SHOW 命令,SELECT 命令不需要跟上 FROM 关键字。同时,变量名需要在 @@ 符号后面,例如 @@max_connections。
3. 设置变量的值
SET max_connections=1000;
执行以上命令后,会将 max_connections 变量的值设置为 1000。
如果想要永久性修改某个变量的值,需要在配置文件中进行修改,例如 my.cnf 文件。在文件中找到对应的变量名,将值进行修改,保存文件之后重启 MySQL 服务即可。
4. 查看建库语句:
show create database xxx