远程连接虚拟机Centos6.5中MySQL18-04-02
1.开放防火墙 3306端口,重启防火墙/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
/etc/rc.d/init.d/iptables save#保存
service iptables restart 2.添加root 远程权限mysql -h localhost -P3306 -u root -p ******
use mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'php' WITH GRANT OPTION;
flush privileges;#重启权限规则3.重启mysql
service mysql restartps. 注意有的直接update mysql.user表,需要重新update Password=password('mysql'),再flush生效。....
sql 根据in条件排序查询结果17-08-14
查询同一张表,不考虑是否有null ,以下是实测模拟百万级用户量多次执行查询,分别执行时间的区间:select count(*) from usero; 0.516s-0.566s
select count(1) from usero; 0.507s - 0.569s
select count(id) from usero;主键 0.655s-0.707s
select count(name) from usero; 普通索引 0.701-0.747s
select count(phone) from usero; 非索引 1.041s-1.138sps: 1.count(*) mysql会转为 count(1),
....
....