posted this in Admin, MYSQL, php, Wordpress on December 4th, 2012 Goal: Update wordpress post with PHP cli
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
< ?php $con = mysql_connect("localhost","root","[redacted]"); if (!$con) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("wordpress")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $myfileText = mysql_real_escape_string(file_get_contents('./code_for_wordpress.html',true)); $sql = "UPDATE `[your_instance_prefix]_posts` SET `post_content` = '$myfileText' WHERE `ID` like '1397';"; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } mysql_close($con); ?> |
posted this in MYSQL on September 19th, 2012 To manually update the CDN Sync Tool table (for wordpress plugin CDN Sync Tool) try this MySQL Insert Statement:
Replace the id with the latest id on your table
|
|
Manually insert row to cdn sync table INSERT INTO `wordpressdb`.`prefix_cst_new_files` (`id`, `file_dir`, `remote_path`, `changedate`, `synced`) VALUES (1567,'/full/path/to/file/filename.txt','filename.txt','1345062888','1'); |
To confirm your work:
|
|
SELECT * FROM `wordpressdb`.`prefix_cst_new_files` where remote_path LIKE `%.txt`; |
posted this in FreeBSD, MYSQL on November 17th, 2011 to move mysql on freebsd without using a dump file follow these steps:
stop mysql copy /var/db/mysql to its new location chown -R mysql:mysql modify /etc/rc.conf and add line mysql_dbdir=”“ modify /usr/local/etc/rc.d/mysql-server and change mysql_dbdir=”/var/db/mysql” to the new location of your mysql directory Start up mysql: /usr/local/etc/rc.d/mysql-server start
posted this in MYSQL on November 15th, 2011 How can you rename a mysql Schema?
easy!
Create the new schema
In this example the new schema is called my_new_schema
|
|
mysqladmin -u root -p create my_new_schema |
Dump the old schema and pipe in to new schema
|
|
mysqldump -u root -p old_schema | mysql -u root -p my_new_schema |
posted this in Linux, Mac, MYSQL, O/S, Other on October 21st, 2011
A ssh port forwarding example would be to map a remote host’s 3306 port to your local machines 3306 port over ssh.
Remote Host: 192.168.0.1 Your Host: localhost
To port forward a mysql connection on a remote host to your local host you would run:
|
|
ssh -L 3306:localhost:3306 username@192.168.0.1 |
Once this is mapped you can use MySQL Workbench . . . → Read More: ssh port forwarding example
posted this in FreeBSD, MYSQL on July 13th, 2011 how to convert ascii mysql db to utf8 ?
I had a MyISAM mediawiki 1.11.0 database that needed to be utf8 to upgrade to the latest version. Before I could upgrade it I had to convert it to utf8.
Here’s the steps on FreeBSD:
|
|
mysqldump -u root -p<removed> --default-character-set=latin1 -c --insert-ignore --skip-set-charset -r wikidb_latin1a.sql wikidb iconv -f ISO8859-1 -t UTF-8 wikidb_latin1a.sql > wikidb_utf8a.sql sed -e 's/character set latin1 collate latin1_bin/character set utf8 collate utf8_unicode_ci/g' -e 's/CHARSET=latin1/CHARSET=utf8/g' wikidb_utf8a.sql > wikidb_utf8_sed_fixed2.sql mysql -u root -p</removed><removed> --execute="CREATE DATABASE wikidbNEW CHARACTER SET utf8 COLLATE utf8_general_ci;" mysql -u root -p</removed><removed> --default-character-set=utf8 wikidbNEW < wikidb_utf8_sed_fixed2.sql |
Nikunj Patel posted this in MYSQL on January 26th, 2011 Ever needed to get all projects associated with every user in redmine? Here’s a query that will help
Multiple Joins sql query; To get user, all projects associated with user and role on that project.
Exmaple:
Table
Column Names
. . . → Read More: redmine all users projects query
posted this in MYSQL, Scripts, Software, Windows on September 24th, 2010 Problem: How can I receive an email when the Redmine admin list changes or a project is changed to publicly viewable? You will need to run some mysql commands / queries in windows batch mode.
Solution:
Download blat and place in c:\windows\system32 Create directory c:\1admin and place these files in it:
These are the queries . . . → Read More: Redmine Alert on New Admin or Public Project
posted this in MYSQL, Software on September 16th, 2010 Howto Backup your Bitnami Instance to a Remote Site for Free What you’ll need 1. Install dropbox to c:\My Dropbox 2. The names of the services bitnami uses (from command line type net start to get list of services) 3. A new local user in the administrator group that will just be used to run . . . → Read More: Howto Backup your Bitnami Instance to a Remote Site for Free
posted this in FreeBSD, MYSQL on July 9th, 2010 Problem: receiving this error on freebsd 6.1
|
|
(Can't contact the database server: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (localhost)) |
To investigate run this command:
If mysql is not running then start it like this:
|
|
# /usr/local/etc/rc.d/mysql-server start |
|
|