涂抹mysql笔记-mysql管理工具
五花八门的mysql管理工具
<>mysql提供的命令行工具
mysql_install_db:mysql建库工具,在源码安装mysql环节我们使用过。
mysql_safe:mysql启动工具
mysqld:mysql主进程,mysql_safe也是调用mysqld进程。启动关闭数据库、查询或修改数据、执行各项维护操作等实际上都是基于mysqld进程的操作。
系统参数:mysql服务启动时的参数
系统变量:mysql服务运行时参数。比如查看与log相关的系统变量使用show global variables like 'log%';系统变量有些可以动态调整而不需要重启mysql,有些则不行。
比如修改mysql数据库认到二进制日志格式为row格式。那么直接修改系统变量set global binlog_format=row;
使用show global variables like 'binlog_format';查看系统变量是否修改。系统变量又分为全局(global)和会话(session)。无论全局还是会话级在下次mysql服务重启后设定就失效,只有在初始化文件中添加才能永久生效。
状态变量:状态变量记录mysql服务的系统状态。状态变量也分为全局和会话,前者记录的是整个mysql服务的状态,而后者只代表当前会话的状态。查看mysql的状态变量:show global status;
系统参数和系统变量之间并不是完全一比一关系,完全存在有参数但没变量,或者有变量却不存在对应参数的情况。
<>mysqld_multi:mysql多实例管理工具需要在my.cnf添加不同的mysqld区块。使用mysqld_multi --example可以参考。这个命令专用于单个服务器上运行多个mysql实例的场景
启动[mysqld34]这个区块:mysqld_multi start 34;
停止[mysqld6] [mysqld7] [mysqld8]三个区块:mysqld_multi stop 6-8;
<>mysql命令:
--auto-rehash:按Tab键补全命令
--default-character-set:用于指定连接会话的字符集
-e,--execute:mysql命令支持两种操作方式,交互式和非交互式。交互式就是引入到mysql命令提示符下执行的操作,非交互式执行mysql命令时,直接指定要执行的语句。比如:
[mysql@linux02 scripts]$ mysql -usystem -poralinux -S /mysql/conf/mysql.sock -e "show slave status\G"
Warning: Using a password on the command line interface can be insecure.
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.6
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000024
...
...
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
-f,--force:在非交互模式批量执行sql语句(或执行一个包含sql语句的文件)时如果要执行的某条sql语句有错误,那么默认情况下改条语句后面所有语句都不会再被执行。例如:
[mysql@linux02 scripts]$ mysql -usystem -poralinux -S /mysql/conf/mysql.sock -e "drop table aa.bbccdd;show slave status\G"
Warning: Using a password on the command line interface can be insecure.
ERROR 1051 (42S02) at line 1: Unknown table 'aa.bbccdd'
上来就报有未知的表对象,后面那个查看slave状态的语句就不执行了。有时候我们希望错误的信息被自动忽略继续执行后面的语句,这时候-f参数就派上用场了。
[mysql@linux02 scripts]$ mysql -usystem -poralinux -S /mysql/conf/mysql.sock -e "drop table aa.bbccdd;show slave status\G" -f
Warning: Using a password on the command line interface can be insecure.
ERROR 1051 (42S02) at line 1: Unknown table 'aa.bbccdd'
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.6
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000024
Read_Master_Log_Pos: 120
Relay_Log_File: mysql-relay-bin.000011
...
...
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
--show-warings:执行完语句后马上显示警告信息,相当于执行完sql语句后要自动执行show warings;语句
system@(none)>help
For information about MySQL products and services, visit:
http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
https://shop.mysql.com/
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'.
clear (\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit (\e) Edit command with $EDITOR.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
For server side help, type 'help contents'
pager是mysql命令行模式中的管道符。
pager more可以分屏显示。pager后面跟的是操作系统命令,可以根据需求换成任何其他命令。nopager取消
prompt修改当前命令行提示符
status特别关注最后两行
tee类似oracle中的spool
<>mysqladmin管理工具
常用参数:
-i,--sleep=#:建个指定时间后,再次重复调用本mysqladmin命令
-r,--relative:当与-i参数联合使用并且指定了extended-status命令时,显示本次与上次之间各状态值之间的差异。
常用命令:
1、create dbname:mysqladmin -usystem -p'oralinux' -S /mysql/conf/mysql.sock create testdb
2、drop dbname:mysqladmin -usystem -p'oralinux' -S /mysql/conf/mysql.sock drop testdb
3、extended-status:查看服务端状态信息,跟在mysql命令行模式下执行show global status的功能一样:
mysqladmin -usystem -p'oralinux' -S /mysql/conf/mysql.sock extended-status
4、flush-hosts:刷新缓存信息
5、flush-logs:刷新日志
6、flush-status:重置状态变量
7、flush-tables:刷新所有表
8、flush-privilege:重新加载授权表,功能与reload命令完全相同
9、reload
10、refresh:刷新所有表并切换日志文件
11、password [new-password]:修改指定用户的密码,功能与set password语句完全相同。
12、old-password [new-password]:修改指定用户密码,只是按照旧的格式修改
12、ping:检查当前mysql服务是的仍能正常提供服务。
mysqladmin -usystem -p'oralinux' -S /mysql/conf/mysql.sock ping
13、debug:输出当前mysql服务的调试信息到error.log文件中,某些情况下性能分析或故障排查非常实用。
14、kill id、id、...:杀掉连接至mysql服务的线程,功能与kill id语句完全相同
15、processlist:查看当前mysql服务所用的连接线程信息,功能完全等同于show processlist;语句
16、shutdown:关闭数据库服务
17、status:查看当前mysql的状态
[mysql@linux02 ~]$ mysqladmin -usystem -p'oralinux' -S /mysql/conf/mysql.sock status
Warning: Using a password on the command line interface can be insecure.
mysqladmin: Unknown OS character set 'GB18030'.
mysqladmin: Switching to the default character set 'utf8'.
Uptime: 3684 Threads: 3 Questions: 60 Slow queries: 0 Opens: 82 Flush tables: 1 Open tables: 75 Queries per second avg: 0.016
下面几个可以作为监控指标:
Uptime:mysql服务启动时间
Thread:当前连接的会话数
Questions:自mysql服务启动后执行查询语句数量
Slow queries:慢查询语句数量
Opens:当前处于打开状态的表对象的数量
Flush tables:执行过flush-*、refresh、reload命令的数量
Open tables:当前会话打开的表对象的数量
Queries per second avg:查询的执行频率
start-salve
stop-slave
variables:显示系统变量功能与show global variables;语句完全相同
version,查看版本信息同时还包括status命令的信息
每隔一秒输出当前mysql服务的状态信息
mysqladmin -usystem -p'oralinux' -S /mysql/conf/mysql.sock -i 1 status
每秒执行查询的数量
mysqladmin -usystem -p'oralinux' -S /mysql/conf/mysql.sock -i 1 -r extended-status |grep -e "Com_select"
<>PHPMyAdmin
XAMPP:对Mysql、Perl、PHP封装各种相关的软件包,以及phpMyAdmin,下载地址:http://www.apachefriends.org/zh_cn/xampp.html
1、解压: tar -xvfz xampp-linux -C /opt
2、vi /opt/lampp/etc/extra/httpd-xampp.conf
在/opt/lampp/phpmyadmin标签中(16-19行之间)增加一行:Require all granted。
将LocationMatch标签中的第62行:Deny from all改为Allow from all 使其他服务器也能访问phpmyadmin
3、启动服务:/opt/lampp/lampp start
4、通过浏览器访问
<>Mysql Workbench
<>第三方管理工具:Sqlyog和Navicat
涂抹mysql笔记-mysql管理工具的更多相关文章
- 常用MySQL图形化管理工具
MySQL的管理维护工具非常多,除了系统自带的命令行管理工具之外,还有许多其他的图形化管理工具,这里我介绍几个经常使用的MySQL图形化管理工具,供大家参考. MySQL是一个非常流行的小型关系型数据 ...
- 涂抹mysql笔记-mysql性能调优和诊断
<>关键性指标1.IOPS(Input/Output operations Per Second)每秒处理的I/O请求次数:需要说明的一点,通常提到磁盘读写能力,比如形容它每秒读300M写 ...
- 涂抹mysql笔记-mysql复制特性
<>mysql复制特性:既可以实现整个服务(all databases)级别的复制,也可以只复制某个数据库或某个数据库中的某个指定的表对象.即可以实现A复制到B(主从单向复制),B再复制到 ...
- 涂抹mysql笔记-mysql数据库文件结构
<>初始化选项文件:默认位置:windows平台 windir\my.ini windir可通过echo $WINDIR$查看 系统盘的根目录即:c:\my.ini installdir\ ...
- iOS核心笔记—源代码管理工具-GIT
源代码管理工具-GIT 一. git 概述 1. git 简介? 什么是git? > git是一款开源的分布式版本控制工具 > 在世界上所有的分布式版本控制工具中,git是最快.最简单.最 ...
- iOS核心笔记—源代码管理工具-SVN
源代码管理工具-SVN 一. 源代码管理工具概述 1. 源代码管理工具的作用? > 能追踪一个项目从诞生一直到定案的过程 > 记录一个项目的所有内容变化,无限制返回 > 查看特定版本 ...
- MySQL图形化管理工具
PHPMyAdmin(关于web界面的) Navicat MySQL Workbench
- 涂抹mysql笔记-mysql字符集
字符集:查看mysql数据库当前都支持哪些字符集:system@(none)>show character set;+----------+--------------------------- ...
- mysql图形化管理工具workbench下载安装以及基本使用
1.下载安装 去mysql官网下载地址进行下载安装 2. 创建schema和表格等基本操作 (1)连接数据库 打开workbench,操作如下: ps:正常需要输入mysql的密码的,但是我之前保存了 ...
随机推荐
- 使用python来访问Hadoop HDFS存储实现文件的操作
原文:http://rfyiamcool.blog.51cto.com/1030776/1258292 在调试环境下,咱们用hadoop提供的shell接口测试增加删除查看,但是不利于复杂的逻辑编程 ...
- libcurl编译使用,实现ftp功能
Libcurl实现ftp的下载,上传功能.版本为curl-7.63.0 1.编译vs2015 参考资料:https://blog.csdn.net/yaojingkao/article/details ...
- 防止asp马后门
好多朋友都拿的有webshell吧,基本上都加了密的... 可是,没见到源码,很难测试它到底有没有后门, 指不定给别人打工了... 下面贴种很简单的方法,大家别扔蛋哈 (asp的哦) 在代码的最 ...
- librdkafka安装和php扩展php-rdkafka安装
1.安装librdkafka mac下 brew install librdkafka linux下 git clone https://github.com/edenhill/librdkafk ...
- [Leetcode 78]求子集 Subset
[题目] Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The ...
- 使用Git上传项目到Gitee
参考原文链接为:https://blog.csdn.net/qq944639839/article/details/79864081 1.打开GitBash 2. cd Client //进入工程目录 ...
- python虚拟环境创建
1.模块安装: pip install virtualenv linux下:pip install virtualenvwrapper(用于workon管理) windows下:pip install ...
- Effective java第17条:要么为继承而设计,并提供文档说明,要么就禁止继承
不要过度设计. 面向对象编程,从一开始被洗脑难免在上手写代码时都会首先思考有没有公共方法啊,能不能把两个类抽象成一个父类再继承啊等,慎重使用继承,当要使用继承时一定要在文档注释中写明重写这个方法会给其 ...
- Python基础01_介绍_HelloWorld
首先,当然是python的版本了,老师讲课学习都是以python3为主, 我的centos中还是python2.6.6 然后参照老师的教程升级到了2.7.14 谢谢! 平时主要练习3的,有时间的情况下 ...
- python自学第13天 hashlib,re模块
import hashlib sha=hashlib.sha3_512()#定义加密成什么格式 sha.update('how to use sha1 in 年后 '.encode('utf-8')) ...