2014年9月24日 星期三

[教學] Mysql DB Migration - mysqldump

這幾年真的記憶力衰退很多! 過去很熟的 Mysql 都已經變得很陌生!

Mysql Database  migration 方法有很多種,其中最傳統的方式就是  mysqldump to other mysql server .

在此小弟寫下來記憶未來有機會才能再翻出來提醒自己.

1.Backup Database on Old Mysql Server
-- Backup one Database on Old Server
# mysqldump -u root -p db_name > db_name.sql; -- Backup all Database on Old Server

# mysqldump -u root -p --all-databases > DB_backup.sql;


2.Create Database on New Mysql Server -- Restore Database to New Mysql Server
-- Restore all DB# mysql -u root -p < DB_backup.sql 



  -- Create New db_name on New Mysql Server
  # mysqladmin create db_name

  # mysql -u root -p db_name < db_name.sql
3.Show user on old Mysql Server
  # mysql
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 369176900
  Server version: 5.0.77-log Source distribution
  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  mysql> show grants for da_rose;         #da is user name
  +----------------------------------------------------------------------------------------------------------------------------+
  | Grants for da@%                                                                                                                               |
  +----------------------------------------------------------------------------------------------------------------------------+
  | GRANT USAGE ON *.* TO 'da'@'%' IDENTIFIED BY PASSWORD '0d4d022f07b97345'   |
  | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON `DIxxxx02db`.* TO 'da'@'%'                         |
  | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON `Dxxxx1db`.* TO 'da'@'%' WITH GRANT OPTION     |
  +-----------------------------------------------------------------------------------------------------------------------+
4.Add user on New Mysql Server
  # Mysql –p root
  mysql> GRANT USAGE ON *.* TO 'da'@'%' IDENTIFIED BY PASSWORD '0d4d022f07b97345' ;
  Query OK, 0 rows affected (0.00 sec)
  mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON `DIxxxx02db`.* TO 'da'@'%' ;
  Query OK, 0 rows affected (0.00 sec)
  mysql> FLUSH PRIVILEGES;
  Query OK, 0 rows affected (0.00 sec)
  mysql> show grants for da;
  +-------------------------------------------------------------------------------+
  | Grants for da@%                                                                      |
  +-------------------------------------------------------------------------------+
  | GRANT USAGE ON *.* TO 'da'@'%' IDENTIFIED BY PASSWORD '0d4d022f07b97345'     |
  | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON `Dxxxx1db`.* TO 'da_rose'@'%'                                                                |
  +-------------------------------------------------------------------------------+


5.Check database connetion status for user site
  # mysql -h $new_mysql_server_ip –u user_name  -p
  mysql> show grants for da;
  mysql> show  databases ;


[教學] Mysql install on Linux


1.Install mysql
 # rpm -i MySQL-server-VERSION.glibc23.i386.rpm
2.Change  mysql home on  the my.cnf
  #  vi /etc/my.cnf
  [mysqld]
  #datadir=/var/lib/mysql
  datadir=/home1/mysql
         And Add  6 line after  “ log-long-format  “
  ###20140811 add by Yen for   performance issue Start
  max_connect_errors=1844674407370954751
  connect_timeout=20
  skip-name-resolve
  slave_net_timeout=30
  ###20140811 add by Yen for  performance issue End
3.Copy  /var/lib/mysql  to /home1/mysql
  # cp –pRP /var/lib/mysql  /home1/mysql
4.Start mysql
# service mysqld start
5.Setting mysql auto start when boot
# chkconfig  --level 2345 mysqld on


2014年1月5日 星期日

[教學]iphone 5/5s ios 7.x Gmail 郵件將"封存" 功能改成 "刪除"

Gmail 有時會有許多垃圾信.想要刪除!但是偏偏升上iOS 7.x 以後就沒有把信丟進垃圾桶的功能了,只剩下封存,後來找了一找終於找到原來只是default 的設定不同!

把步驟寫出來不然自己都不記得了~

1. 找到設定(Setting) ->點選進去



2. 找出 郵件聯絡資訊、行事曆(Mail,Contacts,Calendars)->點選進去





3.找出您想修改的Gmail 的帳號(這是自己取的名稱,如果有許多Gmail 帳號需要一個一個修改) ->點選進去





4. 在 帳號(account) 的地方->點選進去


5.往下來找到進階(Advanced)->點選進去







6. 找出MOVE DISCARDED MESSAGES INTO : 
點選 已刪除的信箱(Deleted Mailbox) 






會變成如下圖 已刪除的信箱(Deleted Mailbox) 要打勾勾:

7.  按下左上角的帳號 (account) ->點選返回




8  按下右上角的 完成(Done) ,就此大功告成



9.回到Gmail 信箱看看吧~



向右滑就可以刪除信件了~