Monday, July 14, 2008

Understanding Google Analytics

Google Analytics provides a way for you to understand your visitor traffic, helping you optimize your site to improve site traffic. By adding code to your web pages, Google's Analytics is called whenever a page is opened. It uses a uniquely assigned tracking code for your account, information about the page opened and information about the ip address and other information such as browser, etc. The results can be viewed on Google's website.

Below is the Dashboard view of jackbriner.com You quickly get information about the number of visitors that you have had in the last month. As you can see, my site has about ten visitors a day. However, there is more to be learned.



As you can see, Google Analytics provides location information. I am pleased that my software and administrative help has spanned the globe with visitors from 55 different countries.


What is even more fun is that it provides further information by drilling down to the city level. So, you can see exactly how your site is being viewed. Here is drilling from the USA down to South Carolina:



There are a couple of questions left to be answered: how did these visitors find my site? Google tracks direct, referred and search related visits.

More specifically we can see which search engines and which referrals are generating traffic.


You will note a variety of parenthesized items after some search engines. These specify how the search engine directed to your site. "Organic" is a visit generated by a search. If I had had any, paid by click advertising that would have shown up differently. Full data is available which may include information on referral sites (some site that has added a link to your page).

Also of interest is what set of keywords drove people to your site. For example, you can see that my C++ Sudoku program is found with "sudoku c++", "sudoku in c++". Also my Joomla password recovery method gets hit fairly fequently.

Another question is my site getting more exposure over time? Analytics will allow you to set a time period. For example, I began my blog about a year ago. You can see that as I have added more to my blog, the more hits the site has gotten.

So, I guess I should keep on writing blogs.


Labels: , ,

Sunday, July 13, 2008

Creating Databases in MySQL

A database in MySQL must be created by user who has permissions to create a database.

One of the easiest tools for database creation is phpMyAdmin , a tool which runs off of your web server in php. It allows you to create databases, tables, etc. If logged in as root, you can add new users (permissions) or create new tables.

Just select privileges and then add user:


For security and following the principle of least privileges and compartmentalization, we want to limit access to the database. By assigning a one-to-one relationship between users and databases, we limit the effects of an attack on our server to one database and not all of our databases. So, with the new user, we create a new database. We also generate a new password which may be generated automatically (by pressing the generate button) and copying it to the fields above. Or, we may use our own password. However, be sure to use a different password than your other databases.


You can create the database for the user at the same time by selecting the appropriate field in the "Database for user" area. For security, do not give any "Global privileges." Press ok at the bottom of the form.

Your user and database have been created with security in mind:
  • one database, one user, unique password - containment and least privileges.
  • localhost requires that any attack on that database must come from within your system.

If you don't have phpMyAdmin or other tool, here are the basic SQL commands:
CREATE USER 'flowertownDB'@'localhost' IDENTIFIED BY '***********';

GRANT USAGE ON * . * TO 'flowertownDB'@'localhost' IDENTIFIED BY '***********' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

CREATE DATABASE IF NOT EXISTS `flowertownDB` ;

GRANT ALL PRIVILEGES ON `flowertownDB` . * TO 'flowertownDB'@'localhost';

Labels: , ,

Wednesday, July 9, 2008

MySQL Root Password Reset

Ok, I admit I am very forgetful. My wife would even say "very, very forgetful." So, besides not remembering my Joomla password (see related article). I forget other passwords like my database passwords.

For MySQL, my recipe for reseting my password is as follows:

As root,
  • Stop currenly running mysql server
    # service mysqld stop 
  • Restart service manually without using permissions
    # mysqld_safe --skip-grant-tables &
  • Connect to service with mysql as root
    # mysql -u root
  • Use mysql database
  • mysql> use mysql;
  • Reset password field for 'root'
    mysql> update user set password=PASSWORD("your-new-password") where User='root';
  • Make sure everything is pushed to server
    mysql> flush privileges;
  • Quit the MySQL client
    mysql> quit
  • Stop the server which is running without permissions
    # kill -TERM %1
  • Restart the service properly
    # service mysqld restart

Labels: ,