linux 上管理mysql_Linux下管理MySql

一、设置MySQL自启动

[root@hqw init.d]# chmod +x /etc/init.d/mysql

[root@hqw init.d]# chkconfig --add mysql

[root@hqw init.d]# chkconfig --level 345 mysql on

[root@hqw init.d]# chkconfig --list mysql

mysql          0:off1:off2:on3:on4:on5:on6:off

[root@hqw init.d]# reboot

[root@hqw ~]# netstat -na | grep 3306

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN

[root@hqw ~]# mysql -h127.0.0.1 -uroot -proot

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.1.73-community-log MySQL Community Server (GPL)

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

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select now();

+---------------------+

| now()               |

+---------------------+

| 2014-12-12 10:49:57 |

+---------------------+

1 row in set (0.00 sec)

mysql>

二、查看mysql安装目录

[root@hqw ~]# whereis mysql

mysql: /usr/bin/mysql /usr/lib/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

[root@hqw ~]# which mysql

/usr/bin/mysql

[root@hqw ~]#

三、查看执行计划

mysql> use ygx;

Database changed

mysql> explain select * from t_page_view_log;

+----+-------------+-----------------+------+---------------+------+---------+------+------+-------+

| id | select_type | table           | type | possible_keys | key  | key_len | ref  | rows | Extra |

+----+-------------+-----------------+------+---------------+------+---------+------+------+-------+

|  1 | SIMPLE      | t_page_view_log | ALL  | NULL          | NULL | NULL    | NULL |    1 |       |

+----+-------------+-----------------+------+---------------+------+---------+------+------+-------+

1 row in set (0.05 sec)

mysql> explain select * from t_org;

+----+-------------+-------+------+---------------+------+---------+------+------+-------+

| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra |

+----+-------------+-------+------+---------------+------+---------+------+------+-------+

|  1 | SIMPLE      | t_org | ALL  | NULL          | NULL | NULL    | NULL |    3 |       |

+----+-------------+-------+------+---------------+------+---------+------+------+-------+

1 row in set (0.00 sec)

mysql> explain select * from t_org t where t.c_id=1;

+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+

| id | select_type | table | type  | possible_keys | key     | key_len | ref   | rows | Extra |

+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+

|  1 | SIMPLE      | t     | const | PRIMARY       | PRIMARY | 8       | const |    1 |       |

+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+

1 row in set (0.00 sec)

mysql>

explain select * from t_org t where t.c_id=1;

会产生如下信息:

select_type:表示查询的类型。

table:输出结果集的表

type:表示表的连接类型

possible_keys:表示查询时,可能使用的索引

key:表示实际使用的索引 key_len:索引字段的长度

rows:扫描的行数

Extra:执行情况的描述和说明

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值