Chinaunix首页 | 论坛 | 博客
  • 博客访问: 350703
  • 博文数量: 166
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1640
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-05 11:44
个人简介

文章不在长,坚持不懈记录下努力前行的脚步

文章分类

全部博文(166)

文章存档

2017年(19)

2016年(59)

2015年(88)

我的朋友

分类: Mysql/postgreSQL

2015-12-22 16:19:51

20151222
主题:mysql_config_editor — MySQL Configuration Utility
(来自MySQL reference manual 4.6.6)
=============================================
语法:
shell> mysql_config_editor [program_options] command [command_options]
command包含set、remove、print

设置login_path
shell> mysql_config_editor set --login-path=client
         --host=localhost --user=localuser --password
Enter password: enter password "localpass" here
shell> mysql_config_editor set --login-path=remote
         --host=remote.example.com --user=remoteuser --password
Enter password: enter password "remotepass" here

查看login_path
shell> mysql_config_editor print --all
[client]
user = localuser
password = *****
host = localhost
[remote]
user = remoteuser
password = *****
host = remote.example.com


设置login-path
1.验证登录
[root@mysqlslave ~]# mysql -uroot -pmysql123
root用户密码正确能登录

2.设置login-path
[root@mysqlslave ~]# mysql_config_editor set --login-path=native --host=192.168.73.130 --user=root --password
Enter password:
WARNING : 'native' path already exists and will be overwritten.
 Continue? (Press y|Y for Yes, any other key for No) : y
输入密码与数据库设置不一致,能创建login-path

3.验证通过login-path是否能登录登录 --不能登录
[root@mysqlslave ~]# mysql --login-path=native
ERROR 1045 (28000): Access denied for user 'root'@'mysqlslave' (using password: YES)

4.重复第2步修改密码与数据库设置一致
5.再次验证通过login-path是否能登录登录 --能登录
[root@mysqlslave ~]# mysql --login-path=native
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.20-log

6.打印一下login-path信息
[root@mysqlslave ~]# mysql_config_editor print --all
[native]
user = root
password = *****
host = 192.168.73.130

==============================
1.上面创建的组为native,此时本地登录不能不指定login-path
[root@mysqlslave ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

2.再创建一个client组
[root@mysqlslave soft]# mysql_config_editor set --login-path=client --host=192.168.73.130 --user=root --password
Enter password:

3.现在可以不知道login-path登录了
[root@mysqlslave soft]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16

4.默认打印的是client组
[root@mysqlslave soft]# mysql_config_editor print
[client]
user = root
password = *****
host = 192.168.73.130
[root@mysqlslave soft]# mysql_config_editor print --all
[native]
user = root
password = *****
host = 192.168.73.130
[client]
user = root
password = *****
host = 192.168.73.130


主题:mysqlbinlog — Utility for Processing Binary Log Files
(来自MySQL reference manual 4.6.8)
=============================================
mysql binlog包含数据库修改操作的文件,文件是二进制形式的,查看文件内容的话的使用mysqlbinlog工具,该工具也可以查看relaylog的内容;

基于语句模式的binlog,其事件包含sql语句,server_id及执行语句的时间戳,sql被执行了多少次等等信息;基于行的包含的是行变化不是sql语句。

# at 141
#100309  9:28:36 server id 123  end_log_pos 245
  Query thread_id=3350  exec_time=11  error_code=0
at后面的数字141表示事件的起始位置或者偏移量,第二行的日期时间表示语句执行的起始时间,复制结构中,这个时间戳被传到从库,server id就是产生事件的server的server_id,end_log_pos表示下一个事件的时间戳,thread_id表示执行事件的线程id,exec_time是在master上事件执行花费的时间,在slave上它表示的是事件在slave上的执行结束时间与master上开始执行的时间的差,这个值在主从上的差异代表着slave落后与master的程度,error_code代表事件执行的结果,0表示没有错误;

binlog中的语句能够被重新执行来重做一些事务,这可用于数据库的崩溃恢复;
一般mysqlbinlog能够读本地binlog并直接应用到本地server,它也能读远程的binlog,这是需要加--read-from-remote-server选项;





阅读(516) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~