Author Archive

MySQL: Updating passwords

Thursday, March 5th, 2009

Updating a password can be done within mysql, by root, thusly:

mysql>use mysql;
mysql>update user set password=PASSWORD(‘[Password]‘) where user=’[Name of user]‘;

Note, to change the password from the account you are already in, you do not need to specify user i.e.:

mysql>set password=PASSWORD(‘[password]‘)

The second designation of PASSWORD is actually a function call, one that encrypts, or hashes the password you supply.

Also, keep in mind that, after any password updates you must flush privileges:

mysql>flush privileges;

And jumping back out to the command line and restarting MySql is not a bad idea, either:

mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start

Info taken from here and here, and, if you really get into trouble, here.

–Joab Jackson

MySql: Adding or dropping a new user

Wednesday, March 4th, 2009

Adding a new user is a three-step process. First you add the user account, and then you grant privileges to whatever databases that person will be using.

1. To add a user, you use the Create User command. Log onto Mysql as root, then, at the prompt, type:

mysql>create user [name of new user];

[MYSQL BUG: The documentation says you can add password onto this line, i.e. "identified by '[password]‘ but YOU CAN’T!!! You could spend all morning wondering why your new client can’t log in because of this SNAFU. Instead, you have to add the password in a separate command (see the section on adding passwords). So, step 2 is:

2. Add password for new user (see separate blog entry).

3. To grant database privileges to the user, you use the grant command. First you stipulate the privileges you want to grant, specify the name of the databases these privileges would apply to, and finally whom all this should apply to. Intuitively backwards.

mysql>GRANT ALL ON [databasename].* TO ‘[username]‘@’[somehost]‘;
mysql>GRANT SELECT, INSERT ON *.* TO ‘[someuser]‘@’[somehost]‘;

Note, that somehost specifies where the host is working from, either remotely (over a network) or on the terminal of the machine where mysql resides (localhost). You can also specify specific IP numbers, I think. If you leave @ off altogether, mysql assumes the user can access these privileges from anywhere.

Also note that using a database usually involves working with multiple files, all under the name of the database but with different suffixes. So that it is usually good to use a wildcard for the suffix of these files for grant privileges.

[MYSQL BUG: The '%' wildcard is deceptive, insofar as it does not grant privileges from the local host, as the documentation states. Instead, you have to grant a set of privileges especially for the localhost, i.e. '[someuser]‘@’localhost’.]

* * *

Dropping a user account can be done thusly:

mysql>drop user [Name of user]

Taken from here

–Joab Jackson

CSS: Adding a background color to a Web page

Sunday, February 22nd, 2009

Since, the last time I built a Web page, the rules have changed for how to adding a background color.It used to be the case that you added an attribute onto the body tag. No longer! That is being deprecated….These days, you use Cascading Style Sheets (CSS).

The easiest way to do this is to embed some CSS code directly into the page itself, in the head section.

<Style type=”text/css”>
body {background-color: #FFEBCD}
</style>

Note, the color above is encoded (“#FFEBCD”) in hexadecimal….Go here to get the hexadecimal codes for your favorite colors.

Some of this info was taken from here.

–Joab Jackson

MySql: How to recover a lost password

Saturday, February 21st, 2009

Locked out of MySQL? here is how you recover access: You stop MySQL. Then, you start MySQL in safe mode, then start the MySQl database itself, set the new password, flush the privileges, exit. Stop and then restart the database in normal mode:

# /etc/init.d/mysql stop
# mysqld_safe –skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD(“newrootpassword”) where User=’root’;
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start

From this compilation of MySQL commands..

–Joab Jackson

PHP: Installing PHP on Ubuntu

Saturday, February 21st, 2009

PHP works as a module on the Apache Web server….

First download and install the PHP package, from root:

#apt-get install php5 libapache2-mod-php5

When PHP is installed, it is run by default by Apache. You need to restart the Apache module for the chnages to take effect:

#/etc/init.d/apache2 restart

To test to see if PHP is running,, save a sample script in the root directory (var/www) under a file with a php extension (i.e phpinfo.php):

<?php
print_r (phpinfo());
?>

Then, open the page in a browser (http://hopstname/phpinfo.php). You should get a page with PHP operational info.

OTHER THINGS TO CONSIDER:

Also, if you PHP in conjunction with MySQL, you need to install the PHP MySql package (if it wasn’t installed during the OS installation):

#apt-get install php5-mysql

PHP also has a terminal client. To install that, enter this in the command line:

#apt-get install php5-cli

From the Ubuntu server guide.

–Joab Jackson

Time: The OS and the delivered time packet

Monday, February 16th, 2009

NTP gets the time to the client, but how does the operating system adjust its own time to this new time? The IETF put forth a generic way in RFC 1589.

The Unix kernel is alerted by a hardware counter interrupt at some fixed rate. In the 1589 scheme, OS’es keep the time by an accumulation of microseconds. It is some multiple of a hardware counter interrupt, which takes place at a periodic fixed rate, depending on the frequency of the counter (Which, by default, must be some divisor of the CPU frequency[?]). If this number does not divide evenly into a microsecond, the OS adds in some small sum periodically.

For instance, in the Ultrix kernel gets interrupted at 256 Hz. Since this does not divide evenly into a microsecond, the kernel adds 64 microseconds in each second.

For Unix systems, the NTP-driven clock adjustments are made using the adjtime()system call. One trick though: The clock frequency is changed by the value tickadj, which means the time can be slewed only by that amount(?). This rounding error can accumulate to such a degree the time is eventually wrong. As a result, a synchronization daemon must make an adjustment(?).

–Joab Jackson

Time: How NTP works

Saturday, February 14th, 2009

The Network Time Protocol (NTP) is used to update a computer’s clock time from a time server over the Internet.

Synchronization is done through an exchange of packets between a NTP time server and the computer, known here as the client. The client sends a request packet to the server, which includes the time the packet was sent (called the “originate timestamp”). When the server receives the packet, it sends back another packet with the time it received that packet (the “receive timestamp”).

When the client gets the receive timestamp, it logs the time again. It can then use its two timestamps, in conjunction with the time on the receive timestamp, to estimate the time.

The current time would be the receive timestamp, plus half the total travel time (The time the receive timestamp was received minus the time that originate timestamp was sent), plus the remote processing time.

A series of these sorts of exchanges are executed to validate the time.

From the NTP FAQ.

–Joab Jackson

Time: NTP on the Ubuntu server:ntpdate (1)

Saturday, February 7th, 2009

Off the bat, the Ubuntu server is installed with ntpdate.

At the command line enter “ntpdate ntp.ubuntu.com” (or some other ntp source)

You’ll get something like this back:

“7 Feb 22:29:34 ntpdate[12786]: step time server 91.189.94.4 offset 40.918237 sec”

ntpdate pulls the time from an ntp server, or more than one. It then adjusts the clock on the server.

The Ubuntu Linux distro runs ntpdate once at boot time. You can also enter it as a daily cron job.

See also NTP FAQ.

–Joab Jackson

Time: Why NTP needs to be upgraded(1)

Saturday, February 7th, 2009

The venerable Network Time Protocol needs to be updated. It increments time in chunks too coarse for modern use.

For instance, how do you measure one-way packet delay from one node to another(through the trusty ping command)?

Well, the current network Time Protocol (NTP) can do it within 20 milliseconds. That was nice back in the day, but these days when it takes 50 nanoseconds to send a packet such a link, a minimum sized packet takes 6 microseconds to traverse the 1 kilometer (10 Gb/s) link. The level of nuance is not enough.

Thinner slices of time could be useful elsewhere too: synchronization at the MAC-address level; for an intra-PoP time transmission mechanism used by the cable company; and for Wi-Max transmitter response times, etc. Likewise, the electrical and printing industry also has the need for time increments less than a few microseconds. And the military is looking into large sensor networks, which need to be synchronized as well.

Note: version 4 of NTP is accurate to about a microsecond, or about 2^-32 seconds.

From the TicToc working group charter and problem statement

–Joab Jackson

Math: Math and logic

Monday, January 26th, 2009

More notes from reading “Is God a Mathematician,” by Mario Livio

Over the centuries the science of mathematics and the study of logic grew more and more intertwined. In the early 20th century, Bertrand Russell argued that mathematics could be reduced to logic.

In the early 20th century, Kurt Godel showed that no formal system could ever “capture the the entire body of truths of mathematics.” (p. 197). All systems are incomplete, and the best we can hope for from any system is that it does not contain any internal inconsistencies.

So, Livio asks, how can an incomplete system be so precise at describing the cosmos?

Livio distinguishes two forms of mathematics: active and passive. Active is pragmatic math–a researcher needs to describe something and uses math to “rely on the perceived similarity between the properties of the mathematical concepts and the … experimental results.” (p. 203).

The other form of mathematics is passive–it is the study of math for its own sake. Practitioners of this sort of math will insist that their work has absolutely no practical benefit.

The strange thing though, is that oftentimes even the most esoteric form of math will eventually be used in in some practical way. Knot theory, for instance.

–Joab Jackson