mysql習慣及主從複製參數設定

來源:互聯網
上載者:User

標籤:

mysql 重複資料插入

replace into t(id, update_time) values(1, now());

replace into t(id, update_time) select 1, now();


MySQL replace into 有三種形式:

1. replace into tbl_name(col_name, ...) values(...)

2. replace into tbl_name(col_name, ...) select ...

3. replace into tbl_name set col_name=value, ...

/************************ svn linux ***************************/

sudo apt-get install subversion

svn checkout 地址 || svn co svn://遠程地址 ./本地地址 --username 使用者名稱 --password 密碼

Available subcommands:
add
blame (praise, annotate, ann)
cat
changelist (cl)
checkout (co)
cleanup
commit (ci)
copy (cp)
delete (del, remove, rm)
diff (di)
export
help (?, h)
import
info
list (ls)
lock
log
merge
mergeinfo
mkdir
move (mv, rename, ren)
propdel (pdel, pd)
propedit (pedit, pe)
propget (pget, pg)
proplist (plist, pl)
propset (pset, ps)
resolve
resolved
revert
status (stat, st)
switch (sw)
unlock
update (up)

 

/************************ php數組比較 ***************************/
$q = array(1,2,30,40,50);
$s = array(1,2,4,8,9,9,34,2,12,324,3,34,343);

//共同的部分
$m=array_intersect($q,$s);

//老的資料
$old=array_diff($q,$m);

//新的資料
$new=array_diff($s,$m);

 


// 欄位唯一值
ALTER TABLE `kcd_diamond` ADD UNIQUE(`dia_report_no`);

伺服器啟動命令:
/usr/sbin/nginx -c /etc/nginx/nginx.conf

// 設定曆史命令的時間


// 查看連接埠佔用情況
nwtstat -an


//
pclose(popen(‘/bin/bash /opt/lampp/htdocs/restart.sh‘,‘r‘));


// 殺掉進程

#!/bin/bash
ps x | grep ‘./wbserver‘ | grep -v grep | grep -v "‘./wbserver‘" | awk ‘{print $1}‘ | xargs kill -9

重新啟動


/*********************************** MYSQL *****************************************************/


grant all privileges on *.* to [email protected] identified by ‘pass‘;
flush privileges;

查看MYSQL資料庫中所有使用者
mysql> SELECT DISTINCT CONCAT(‘User: ‘‘‘,user,‘‘‘@‘‘‘,host,‘‘‘;‘) AS query FROM mysql.user;

mysqldump -uroot -p kcvdiamond kcd_diamond --where=" dia_sup_id=10020" > /home/diamond.sql


python 資料總結

安裝pip

wget https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz#md5=3823d2343d9f3aaab21cf9c917710196
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-18.3.2.tar.gz#md5=d30c969065bd384266e411c446a86623

// 檔案中尋找欄位

find . -name "*.log" | xargs grep ""

// find . -name "*.log" | xargs grep 192.168.3.75

// 主從複製mysql

 

CHANGE MASTER TO MASTER_HOST=‘server1‘,MASTER_USER=‘repl‘,MASTER_PASSWORD=‘p4ssword‘,MASTER_LOG_FILE=‘mysql-bin.000001‘,MASTER_LOG_POS=0;

// 匯出資料
/opt/lampp/bin/mysqldump -uroot -p kcvdiamond -l -F > t1.sql

mysqldump -uroot -pIsmond258369 kcvdiamond kcd_diamond --where=" dia_sup_id=10020" > /home/hkgroup.sql

// 匯入資料
/opt/lampp/bin/mysql -uroot -p kcvdiamond < t1.sql

replicate-do-table=hrsoft_share.表名# 只複製表名表

// 複製表資料
insert into dist_systerm_msg (mg_title,mg_cont,mg_type,mg_user,mg_time,mg_ipad_uuid,mg_ipad_token) (select mg_title,mg_cont,mg_type,mg_user,mg_time,mg_ipad_uuid,mg_ipad_token from dist_systerm_msg);

// 嚴格來說以下兩點少用, 逃避錯誤

1.跳過指定數量的事務:
mysql>slave stop;
mysql>SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1 #跳過一個事務
mysql>slave start

2.修改mysql的設定檔,通過slave_skip_errors參數來跳所有錯誤或指定類型的錯誤
vi /etc/my.cnf
[mysqld]
#slave-skip-errors=1062,1053,1146 #跳過指定error no類型的錯誤
#slave-skip-errors=all #跳過所有錯誤


mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.3.136
Master_User: user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000004
Read_Master_Log_Pos: 2346
Relay_Log_File: localhost-relay-bin.000014
Relay_Log_Pos: 1106
Relay_Master_Log_File: mysql-bin.000004
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table: test.t_test
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 2346
Relay_Log_Space: 1283
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: 4985efad-79a0-11e5-a6a0-000c29ced604
Master_Info_File: /opt/lampp/var/mysql/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
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

mysql習慣及主從複製參數設定

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.