mysql
This is an old revision of the document!
−Table of Contents
python mysql
import MySQLdb postCnt = cursor.execute('select id,post_content from wp_posts') #434L 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))
references
- Python MySQL from 권남이님의 스프링노트
backup / restore
백업
mysqldump --single-transaction --opt -u $DBUSER -p$DBPASS $DBNAME > backup.sql
복구시에는 DB와 User 생성 필요:
$ mysql -u adminusername -p mysql ... mysql> create user 'blog_admin'@'localhost' identified by 'password'; mysql> CREATE DATABASE databasename; mysql> GRANT ALL PRIVILEGES ON databasename.* TO "wordpressusername"@"hostname" -> IDENTIFIED BY "password"; mysql> FLUSH PRIVILEGES; mysql> EXIT
blog restore
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)
mysql.1249363201.txt.gz · Last modified: 2013/08/03 05:04 (external edit)