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