mysql4u.com


Mysql Connector/J

Posted in JDBC Driver by mysql4u on the September 12th, 2008

Mysql Connector/J(For Java) is a typical native java driver that converts JDBC calls into the network protocol that is used by the MYSQL Database.

It helps Java Developers integrate Mysql with java in a very heterogeneous and Loosely coupled architecture.

You can download the Java Connector for Mysql from mysql website.

Two versions of MySQL Connector/J are available for download:

MySQL Connector/J 3.1 is the old production-ready version of the driver, and is available under the GPL.
MySQL Connector/J 5.0 is another old production-ready version of the driver, and is available under the GPL.
MySQL Connector/J 5.1 is the current production-ready version of the driver, and is available under the GPL (recommended).

My next blog will describe how to use mysql with Java in a programming environment using Tools like eclipse for product development for heterogeneous environments.

Till Then,
Ciaonara !
–Ron

Automating Optimization Of Your MySQL Websites

Posted in Optimization by mysql4u on the April 24th, 2008

In my quest to make our clients MySQL driven ecommerce websites running fast, I’ve pieced together a script and cron job that will save you some support calls down the road.

Step 1: Create a PHP optimize script

// Change vars as needed here

$server = “localhost”;

$user = “mysql_user”;

$pwd = “mysql_password”;

$dbName = “mysql_dbName”;

$link = mysql_connect($server, $user, $pwd);

if (!$link) {

die(’Could not connect: ‘ . mysql_error());

}

$db_selected = mysql_select_db($dbName, $link);

if (!$db_selected) {

die (’Can’t use $dbName : ‘ . mysql_error());

}

// Find all tables in the selected DB

$alltables = mysql_query(”SHOW TABLES”);

// Process all tables.

while ($table = mysql_fetch_assoc($alltables))

{

foreach ($table as $db => $tablename)

{

// Optimize them!

mysql_query(”OPTIMIZE TABLE ‘”.$tablename.”‘”)

or die(mysql_error());

}

}

mysql_close($link);

?>

Step 2: Add this script into your daily cron jobs

Most popular Linux distros will have a /etc/cron.daily directory. Login as root and follow these steps to add your new website optimization script to your daily cron directory, thus never having to worry about manually optimizating again!

cd /etc/cron.daily

echo ‘#!/bin/sh’ > mysql_optimize; echo ‘/path/to/your/script.php’ >> mysql_optimize; chmod 755 mysql_optimize;

Now your all set! A quick and easy way to keep your high volume MySQL driven websites optimized!

We have found this script/cron to be very valuable with our high load web design projects that use large MySQL tables. It is most effective on tables that get updated a lot (with deletions and inserts).

John Miller is a website designer at Syberplex Web Design operating out of Minnesota. Our Minnesota Web Site Design firm offers custom small business web site design, ecommerce, redesign services, and search engine optimization.

Article Source: http://EzineArticles.com/?expert=Johnny_D_Miller

Apache, MySQL & PHP for Windows

Posted in Windows, Apache, Mysql PHP by mysql4u on the March 9th, 2008

Apache, MysQL and PHP for Windows could be a nice nice thing to have on your Windows workstation. You could try and experiment with all kinds of nice PHP and MySQL based applications right on your Windows desktop running Apache, instead of having to access a full-featured server.

Most people have Windows as their workstation and it can be sometimes difficult to switch to another operating system. So, you may have always wanted to run PHP applications on your Windows machine but wondered if it is too difficult to install or if the hassle will be worth it.

This article gives you the essential information to get started right away. Even if you are a seasoned PHP, MySQL and Apache guru, the checklist below will still be helpful in your installation process.

There are lots of 3rd party software that bundles Apache, MySQL & PHP in one package and installs them on our computer. We do not recommend this and suggest that you directly get Apache, MySQL & PHP from their official sites.

Apache

1. Get Apache 1.3.33 from here: http://httpd.apache.org/download.cgi.

2. Choose a mirror close to you and in the same page, look for the Win32 Binary (Self extracting) file: apache_1.3.33-win32-x86-no_src.exe.

3. Download the file and save it on your hard disk. Run the installer and the self- extracting wizard will guide you through the rest of the steps. Choose all the default settings and run Apache as a service.

4. Remember to put “localhost” when asked for a Server name/Domain name. Use “administrator@localhost” when asked for the administrative email account.

5. Now point your browser to: http://localhost and you should see an Apache Test Page.

6. You can change this page by creating an “index.html” page here “C:Program FilesApache GroupApachehtdocs”.

7. You can manually start and stop the Apache server. In a Windows command prompt, type “net stop apache” or “net start apache”.

MySQL

1. Get MySQL 4.1.7 from here: http://dev.mysql.com/downloads/mysql/4.1.html

2. Under the Windows downloads section, choose Windows Essentials (x86) and click on the Pick a Mirror link.

3. Download the file mysql-4.1.7-essential-win.msi and save it on your hard disk. Run the installer and the self-extracting wizard will guide you through the rest of the steps. Remember the root password when prompted for it in the installation process.

4. Once the installation is done, on your Windows toolbar, go to “Start->Programs- >MySQL->MySQL Server 4.1->MySQL Command Line Client”.

5. Type the root password and you should be logged in to the MySQL shell.

6. Type “show databases;” to see the list of databases. Type “quit” when you are done.

PHP

1. Get PHP 4.3.10 from here: http://www.php.net/downloads.php

2. Under the Windows Binaries section, choose the file: PHP 4.3.10 zip package size 7,405Kb dated 15 Dec 2004.

3. Download the file and save it on your hard disk. Unzip the file and rename the extracted folder to “php”. Now move this folder “php” and place it under “C: Program Files”.

4. Move all the files under “C:Program Filesphpdlls” and “C:Program Filesphpsapi” to here: “C:Program Filesphp”.

5. Copy the file php.ini-recommended to “C:WINDOWS” and rename it to php.ini

6. Edit your Apache “httpd.conf” configuration file located here: “C:Program FilesApache GroupApacheconf”.

7. Add the following lines in httpd.conf:

LoadModule php4_module “C:/Program Files/php/php4apache.dll”
AddModule mod_php4.c
AddType application/x-httpd-php .php

8. Now stop your server by issuing the following command in Windows command prompt: “net stop apache”. Then type “net start apache” to start your server. We are now going to test the PHP installation.

9. Go to “C:Program FilesApache GroupApachehtdocs” and create a file test.php

10. Edit test.php and add the following code:

phpinfo();
?>

11. Point your browser to http://localhost/test.php and you should see a lot of PHP configuration information.

Congratulations! You now have Apache, MySQL and PHP installed in your computer. Now you can install your favorite script right on your Windows workstation.

Sanjib Ahmad, Freelance Writer and Product Consultant for Business.Marc8.com - Business Best Sellers.

Should I Learn PHP and MySQL or Not?

Posted in WordPress, Mysql PHP by mysql4u on the February 15th, 2008

I’ve had quite a few people ask me this question: “Should I learn PHP and MySQL?”.

The answer is never easy. It all depends on what you’re trying to accomplish. Are you looking to be involved in your own website? Is it being run on PHP and MySQL? What would you like to do with your website?

There’s a million questions you can ask yourself. I, personally, believe that anyone who wants to become more involved with their own website or run their own Web Design and Development Company should, at the minimum, learn the basics of PHP and MySQL.

Why should you? Well, let’s take a few examples…

Maybe you want to create a Members are on your site and you want to be able to offer downloads, use a more interactive Contact script, show information dynamically for your customers (i.e. Time and Date, Their personal information, the information they searched for last, Billing information, Download history, username and/or password, etc) to make it easier for them to browse through your site.

Maybe you want to be able to use PHP for your Search Engine Optimization needs? Needs such as 404 Redirects, 301 redirects, etc.

Maybe you need to create a built in search system for your e-commerce site? Maybe you’re looking to simply redirect people to an Affiliate program?

See the many, MANY ways you can use PHP? It’s a very valuable tool to know and understand. Imagine yourself having the knowledge to take a product like Wordpress and fully customize it to your own, personal, needs?

Think you can make money off of one of your Wordpress Plugin Ideas by knowing PHP? Think you can build a better Content Management System than what’s currently available? What about a new Social Networking Script - OR Community?

Companies like PHPFox have made a killing with their php knowledge. Likewise for companies such as Mambo, vBulletin and various other scripts that you can purchase.

So the next question would be HOW you can learn PHP?

There’s a million ways to learn but I try to explain to everybody that watching Videos and DOING the coding practices they ask you to do is how you’ll learn quickly.

Sure… lot’s of people have learned PHP by reading books. But I find the problem with books is a lack of support. You’re always going to learn more by seeing and doing rather than reading and doing. Luckily there are solutions to this problem.

You can also visit popular forums such as Sitepoint, Digitalpoint and other Webmaster related forums or communities that allow other members to help with questions and answers.

No matter what you choose to do - just remember that DOING is how you learn. Practice without reading or watching. Just take the little knowledge you have at the time and make it grow with practice.

I hope you figure out what you need to accomplish and good luck!

Want to learn PHP at rapid speed? Check out these awesome Video Tutorials I’ve found!

If you’re looking to become a PHP programmer - you need to see these videos!

« Previous PageNext Page »