Archive

Archive for the ‘mysql’ Category

WordPress: using MySQL repair broken links

December 29th, 2010 No comments

Checking my blog that is made WordPress 3.0.3 I noticed that in some posts / articles there were no Internet addresses of wikipedia http:// This meant that if a reader clicks on the link was redirected to www.marcobruni.info / wordpress / address that does not exist, instead of going right on the link to wikipedia.

The “guilt” chrome that is comfortable for a shorter address that starts out on his bar eliminating http:// but this means that if a copy of the bar and paste for example in the post I'm writing I will create a broken link. To solve the problem of the link does not work, I logged into my area of Aruba, and through PhpMyAdmin (Aruba, which provides for the administration of MySQL database) I did a query to find all articles that have this problem:

SELECT * FROM  `wp_posts` 
WHERE `post_content` LIKE '%href="it.wikipedia.org%' AND `post_status` =  'publish'

The query sql basically look at the table of contents (table wp_posts) those whose content (the post_content field) has within the string href =”it.wikipedia.org (without notice http://) and that the articles are published (The `post_status` = ‘publish’).
Finally, through the means of adding PhpMyAdmin I modified the post http:// before it.wikipedia.org.

Categories: Aruba, mysql, sql, wordpress Tags: , , ,

How to create a table in PHP in a MySQL database

December 22nd, 2010 No comments

In this article we will see in Php you can create a table in a database MySQL. Before we tackle the config.php file in which there are parameters to connect to MySQL server and the PHP functions for connecting and then tackle the file for table creation, the end of the post you'll find inside the zip with the 2 php file that you can download to do all the tests you want.

Read more…

MySQL: exclude databases from mysqldump

December 6th, 2010 No comments

Mysqldump is a utility that generates an ASCII file which contains SQL statements (CREATE TABLE, CREATE DATABASE ecc.) that allow you to completely recreate a database. This method allows you to use the script on any platform, thereby obtaining a portable solution. The second important characteristic is flexibility, modifying the script product, You can also restore a single table. Finally effetture mysqldump can dump a database from remote.

Example:

1
2
[stray root @ backup-db]# mysqldump arnaldoz > arnaldoz_dump_db.sql -u root -p  
Enter password: db3mendo

In this case, dump the database arnaldoz generating their instructions in the file arnaldo_dump_db.sql. And’ need to tell you that you will use mysqldump-u root administrator with the password-p

Mysqldump has an option to ignore specific tables. So if you have 1.000 tables in a database, You can tell mysqldump to save all the tables except a few. There is no option to exclude one or more databases. However, if you know the command-line tool, the solution is easy:
First, you get the list of all databases:

1
mysql -B -N -e 'show databases' information_schema employees five four mysql one performance_schema six test three two

-B forces batch mode , -N and get the result without headers.
Now, we say that we want to exclude four database, five six. And because we want to avoid unpleasant side effects, INFORMATION_SCHEMA and also performance_schema. So, we conducted the previous data through a filter. I use Perl, sed or grep, but they could do the same good work.

1
mysql -B -N -e 'show databases' | \ perl -ne 'print unless /b(?:four|five|six|_schema)\b / 'employees mysql test one two three

Now that we have the list of databases we need, we spend a mysqldump for backup. Using the list xargs convert vertical to horizontal.

1
mysql -B -N -e 'show databases' | \ perl -ne 'print unless /b(?:four|five|six|_schema)\b/' \ xargs echo mysqldump mysqldump-B-dependent B-mysql test one two three

Everything here. Once you're sure it's what you want, remove “echo” dopo xargs, and the command is executed.

Source: openskill.info

Categories: mysql Tags: