User Tools

Site Tools


mysql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
mysql [2009/08/04 02:24] – created suapapamysql [2013/08/03 05:04] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== python mysql ======
 +<code python>
 +import MySQLdb
 +db = MySQLdb.connect(db='dbname', user='username', passwd='password', host='localhost')
 +#cursor = db.cursor()
 +cursor = db.cursor(MySQLdb.cursors.DictCursor)
 +#(필드명,데이터형_코드, 표시크기, 내부크기, 정확도, 비율, nullable)
 +cursor.description #(('id', 8, 3, 20, 20, 0, 0), ('post_content', 252, 9933, -1, -1, 0, 0))
 +postCnt = cursor.execute('select id,post_content from wp_posts') #434L
 +</code>
 +
 +<img src="/wordpress/wp-content/uploads/2008/01/sfxn_in_t2_01.jpg" 
 +
 +===== references =====
 +  *[[http://kwon37xi.springnote.com/pages/750237|Python MySQL]] from 권남이님의 스프링노트
 +
 ====== backup / restore ====== ====== backup / restore ======
 백업 백업
Line 6: Line 22:
 복구시에는 DB와 User 생성 필요: 복구시에는 DB와 User 생성 필요:
 <code mysql> <code mysql>
-$ mysql -u adminusername -p +$ mysql -u adminusername -p mysql 
-Enter password: +... 
-Welcome to the MySQL monitor Commands end with ; or \g. +mysql> create user 'blog_admin'@'localhostidentified by 'password'
-Your MySQL connection id is 5340 to server version: 3.23.54 +
-  +
-Type 'help;or '\hfor help. Type '\cto clear the buffer. +
- +
 mysql> CREATE DATABASE databasename; mysql> CREATE DATABASE databasename;
-Query OK, 1 row affected (0.00 sec) 
-  
 mysql> GRANT ALL PRIVILEGES ON databasename.* TO "wordpressusername"@"hostname" mysql> GRANT ALL PRIVILEGES ON databasename.* TO "wordpressusername"@"hostname"
     -> IDENTIFIED BY "password";     -> IDENTIFIED BY "password";
-Query OK, 0 rows affected (0.00 sec) 
-   
 mysql> FLUSH PRIVILEGES; mysql> FLUSH PRIVILEGES;
-Query OK, 0 rows affected (0.01 sec) 
- 
 mysql> EXIT mysql> EXIT
-Bye +</code> 
-+모든 테이블 지우기 
 +<code mysql> 
 +mysqldump --single-transaction -uID -pPASS --add-drop-table --no-data DB_NAME \ 
 +| grep ^DROP \ 
 +| mysql -uID -pPASS DB_NAME
 </code> </code>
  
 +====== blog restore ======
 +<code mysql>
 +mysql> select option_name,option_value from wp_options where option_name='siteurl';
 ++-------------+----------------------------------+
 +| option_name | option_value                     |
 ++-------------+----------------------------------+
 +| siteurl     | http://www.suapapa.net/wordpress |
 ++-------------+----------------------------------+
 +1 row in set (0.00 sec)
 +
 +mysql> update wp_options set option_value='http://web.suapapa.net:8080/wordpress' where option_name='siteurl';
 +Query OK, 1 row affected (0.00 sec)
 +Rows matched: 1  Changed: 1  Warnings: 0
 +
 +mysql> select option_name,option_value from wp_options where option_name='siteurl';
 ++-------------+---------------------------------------+
 +| option_name | option_value                          |
 ++-------------+---------------------------------------+
 +| siteurl     | http://web.suapapa.net:8080/wordpress |
 ++-------------+---------------------------------------+
 +1 row in set (0.00 sec)
 +
 +</code>
mysql.1249352699.txt.gz · Last modified: 2013/08/03 05:04 (external edit)