L004-oldboy-mysql-dba-lesson04
[root@web01 mysql]# mysql -uroot
-ptestpassword -S /tmp/mysql.sock
mysql> select
inet_aton('192.168.1.200');
+----------------------------+
| inet_aton('192.168.1.200') |
+----------------------------+
|
3232235976 |
+----------------------------+
1 row in set (0.00 sec)
mysql> select
inet_aton('192.168.1.200');
+----------------------------+
| inet_aton('192.168.1.200') |
+----------------------------+
|
3232235976 |
+----------------------------+
1 row in set (0.00 sec)
mysql> create database mydb;
use mydb;create table ip(ip int);
insert ip
values(inet_aton('192.168.1.200'));
mysql> insert ip
values(inet_aton('192.100.2.22'));
insert ip
values(inet_aton('172.16.32.15'));
insert ip values(inet_aton('200.100.2.22'));
insert ip
values(inet_aton('200.100.2.100'));
insert ip
values(inet_aton('200.100.3.150'));
mysql> select * from ip;
+------------+
|
ip |
+------------+
| 2147483647 |
| 2147483647 |
| 2147483647 |
| 2147483647 |
| 2147483647 |
| 2147483647 |
+------------+
6 rows in set (0.00 sec)
mysql> create databases mydb;
use mydb;
create table ip_info(
id int unsigned not null auto_increment,
userid int unsigned not null,
username varchar(100) default '',
ip int unsigned not null,
ctime timestamp default current_timestamp
on update current_timestamp,
primary key(id),
index username(username),
index userid(userid),
index ip(ip)
);
show create table ip_info;
insert into ip_info(userid,username,ip)
values(11,'aa',inet_aton('192.168.1.10'));
select * from ip_info;
1.记录慢查询里面的有三种语句,除了这个还可能是没有使用上索引,以及DML操作语句。
2.此变量是动态变量,可以在线设置,设置要是基于session的话,可能会导致不生效,设置为global的话,如果连接不断开也会出现不马上生效的情况。