MySQL中什么询问当前正值运营的SQL语句,mysql服务

2019-07-05 作者:数据库   |   浏览(78)

经过status命令,查看Slow queries这一项,要是值长日子>0,表明有查询试行时间过长

设置完mysql,运营后意识服务器暗中认可使用的是lat1编码.
 
具体操作和查阅进程如下:
 
起步格局: /etc/init.d/mysql.server start
 
效果:
 
Database changed

复制代码 代码如下:

mysql> status

mysql  Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64) using readline 5.1
 
Connection id:        8
Current database:    demodb
Current user:        [email protected]
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        5.5.21 MySQL Community Server (GPL)
Protocol version:    10
Connection:        Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    utf8
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:        /var/lib/mysql/mysql.sock
Uptime:            33 sec
 
Threads: 7  Questions: 137  Slow queries: 0  Opens: 83  Flush tables: 1 

**以下为援用的剧情:

Open tables: 76  Queries per second avg: 4.151

 
mysql>
 
 
起头格局: /etc/init.d/mysql.server start --character-set-server=utf8
 
效果:
mysql> use demodb;
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> status;

mysql Ver 11.18 Distrib 3.23.58, for redhat-linux-gnu (i386)
Connection id: 53
Current database: (null)
Current user: [email protected]
Current pager: stdout
Using outfile: ''
Server version: 5.0.37-log
Protocol version: 10
Connection: Localhost via UNIX socket
Client characterset: latin1
Server characterset: latin1
UNIX socket: /tmp/mysql.sock
Uptime: 4 days 16 hours 49 min 57 sec
Threads: 1 Questions: 706 Slow queries: 0 Opens: 177 Flush tables: 1 Open tables:

mysql> status;

mysql  Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64) using readline 5.1
 
Connection id:        4
Current database:    demodb
Current user:        [email protected]
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        5.5.21 MySQL Community Server (GPL)
Protocol version:    10
Connection:        Localhost via UNIX socket
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:        /var/lib/mysql/mysql.sock
Uptime:            1 min 15 sec
 
Threads: 4  Questions: 131  Slow queries: 0  Opens: 84  Flush tables: 1 

52 Queries per second avg: 0.002

那儿再通过show processlist命令来查看当前正值运行的SQL,从中找寻运维慢的SQL语句,找到实践慢的口舌后,再用explain命令查看这么些讲话的进行安排。
mysql> show processlist;
---- ------ ----------- ------ --------- ------ ------- ------------------
| Id | User | Host | db | Command | Time | State | Info |
---- ------ ----------- ------ --------- ------ ------- ------------------
| 53 | root | localhost | NULL | Query | 0 | NULL | show processlist |
---- ------ ----------- ------ --------- ------ ------- ------------------

queries这一项,如若值长时间0,表明有查询实践时间过长 复制代码 代码如下: 以下为援用的开始和结果: mysql status; -------...

Open tables: 77  Queries per second avg: 1.746

 
mysql>
 
这种情势,在每一遍运行的时候都急需钦命编码参数.否则服务器就应用的是系统暗中认可的lat1编码.
 
 
其余一种艺术是:
 
mysql>set character_set_server=utf8;
 
这种措施本身也试了,不行,再另行登陆客户端后,就又借尸还魂了原先的编码.理由很轻易,系统运营的时候用的不是utf8编码.
 
 
一劳永逸的方式,就是经过改变配置文件实现.
 
# vim /etc/my.cnf
 
剧情如下:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
 
#加上底下的红字内容
character-set-server=utf8
 
 
 
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
 
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
 
 
 
|----------------------------------------------------------------------------------------|
                           版权评释  版权全体@zhyiwww

. 具体操作和查看进度如下: 运营情势: /etc/init.d/mysql.server start 效果: Database changed mysql s...

本文由www.bifa365365.com发布于数据库,转载请注明出处:MySQL中什么询问当前正值运营的SQL语句,mysql服务

关键词: www.bifa3653