Connecting to the Right MySQL Database – Tips and Tricks

Recently, I had to set up a second MySQL database instance on a machine, and found myself wondering which database I was really connecting to with the mysql client.

How do I make sure? This turns out to be rather easy:

mysqladmin -p -u root variables

Add the appropriate options to connect to the database you want – options like a) --socket (socket path); b) --protocol (specify protocol); c) --port (port); and several others.

When you run mysqladmin, there will be a large set of variables listed. Check datadir – it will show you where the database is located on disk. Also check socket: it shows where the mysql socket is which is used for communications. TCP communications will be done through a port, shown as port in the variables listing.

If you run mysql specifying the port, you might be surprised to see that it is ignored. Unless the client is forced to use TCP (via the --protocol parameter) or it picks TCP (through the use of the --hostname parameter) the client will use the specified socket instead.

To force TCP, you can use one of these commands:

mysql --protocol=TCP --port=3311 -p -u root

mysql --host=hostname --port=3311 -p -u root

Alternately, instead of forcing TCP, specify the local socket:

mysql --socket=/var/lib/mysql2/mysql.socket -p -u root

You can specify these options with mysqladmin to verify the actual database (using the variables command). There are short versions of these options (separate them from arguments by a space, not an equals):

  • host: -h
  • port: -P
  • socket: -S

OpenSolaris is Officially Dead

We saw this coming.

As of 23 August 2010, the OpenSolaris Governing Board (OGB) has stepped down; Ben Rockwood posted the resolution on his blog.

Oracle’s previous email to staff shows that Oracle has no interest in keeping OpenSolaris going, and now there is no one minding the store.

The next step lies with Illumos, the new torch-bearer for open source Solaris. Nexenta, the commercial UNIX based on OpenSolaris and a GNU userland will probably be the first to use Illumos (the project has close ties to Nexenta) – and Belenix may be next, although Belenix development seems to be quite slow (there is no corporate sponsorship and the community seems to be small). Belenix has the tougher problem, as they use a Solaris-based userland.

Oracle’s Plans for OpenSolaris Murkier than Ever

The controversy around the future of OpenSolaris has been building to a fever pitch these last few weeks, most recently leading to the creation of Illumos, a new open source kernel tree based on the open source portions of OpenSolaris.

Way back in July of 2009, Steven Vaughn-Nichols suggested that OpenSolaris would wither on the vine through deliberate neglect by Oracle – and this seems to be happening (whereas his prediction of the same treatment for MySQL and VirtualBox seems to be misplaced). Then in February of 2010, Ben Rockwood wrote an open letter to Oracle about the future of Solaris and OpenSolaris.

Oracle’s most recent response (during an interview with ServerWatch) has been to state that development on Solaris continues apace, and that Solaris 11 is due out by the end of 2011. Most notable was the lack of any discussion on the future of OpenSolaris.

A few months ago, the OpenSolaris Governing Board – in effect, the people in charge of the details of operating the OpenSolaris community and its resources – are willing to resign en masse if Oracle does not talk to them; Peter Tribble (a member of the OpenSolaris Governing Board) talks about this action in his blog.

I agree with those that say that Oracle can do what it likes, and the threat made by the board is empty – not because of the threat itself, but because it will accomplish nothing, and has no effect on Oracle. If Oracle wants OpenSolaris to go away, it doesn’t matter what the OpenSolaris community thinks. The Governing Board simply has no leverage with Oracle.

No word on how this action will affect Belenix; while Nexenta is basically the OpenSolaris kernel plus a Debian/GNU userland, Belenix is an OpenSolaris kernel plus a mostly Solaris userland. The primary founder of Belenix (Moinak Ghosh) is on the OpenSolaris board; one of the other developers (Sriram Narayanan?) blogged about the board’s action shortly after it was taken in July. Perhaps Belenix would use the Illumos kernel as well?

However, the prospect of OpenSolaris living on in the form of Illumos is promising, and technologies that are part of the open source OpenSolaris will not be lost. Nexenta has already stated its interest in Illumos; this is perhaps because Nexenta relies on OpenSolaris (with its now doubtful future) for its kernel. Thus, it is perhaps no surprise that a Nexenta engineer is the driving force behind Illumos, and neither is it a surprise that Illumos is currently a kernel only.

So now – how long before we see a Debian/Illumos project? Or is that Nexenta now?

CommunityOne West: June 1-3 2009

Sun is holding its CommunityOne West conference at the Moscone Center June 1-3 in San Francisco, California.

Sounds like there will be a wide range of Solaris and Open Source topics, including virtualization, system management, cloud development, mobile development, web development, and much more.

The OpenSolaris community will be there in force, so don’t miss it!

This is one of the first conferences since Oracle announced their acquisition of Sun; it would be interesting to be plugged into the rumour mill on the floor.

Did anyone go to CommunityOne East in New York City?

Powered by ScribeFire.

How much memory is in the box? (all UNIX, OpenVMS)

How much memory is in this machine?

It would seem that answering this question ought to be easy; it is – but every system has the answer in a different place. Most put an answer of some sort into kernel messages reported by dmesg (AIX apparently does not).

Most systems have a program for system inventory which reports a variety of things, including memory.

Rather than go into great detail about each one, we’ll just put these out there for all of you to reference. Each environment has multiple commands that give available memory; each command is listed below.

Without further ado, here are a few answers to this burning question:

Solaris

  1. dmesg | grep mem
  2. prtdiag | grep Memory
  3. prtconf -v | grep Memory

AIX

  1. bootinfo -r
  2. lsattr -E1 sys0 -a realmem
  3. getconf REAL_MEMORY

HPUX

  1. dmesg | grep Physical
  2. /opt/ignite/bin/print_manifest | grep Memory
  3. machinfo | grep Memory

Linux

  1. dmesg | grep Memory
  2. grep -i memtotal /proc/meminfo
  3. free

OpenVMS

  1. show mem /page

Update:

FreeBSD

  1. dmesg | grep memory
  2. grep memory /var/run/dmesg.boot
  3. sysctl -a | grep mem

Finding devices for your open source operating system

In a Windows environment, people have gotten used to just picking up any device (whether it is a CDROM, PCMCIA card, printer, or modem) and expecting it to work. While the concept of “plug and play” is not yet here, the fact is that when installed everything should work with Windows.

And it isn’t just Windows – other large commercial vendors have access that you and I do not. Apple comes to mind – MacOS X has much better support than Linux or FreeBSD, for example.

Open source operating systems rely on hardware manufacturers to make the details of their hardware available for free or low cost – and then for someone to come and craft the software drivers needed. Usually, the latter is not a big problem; the former is.

The problem can be deeper than that as well, since the label on the product is not the same as the label on the internal devices: so it is not possible to simply look for a brand and use it. Worse, manufacturers can change hardware vendors on the same model, so that discerning which model is which can occasionally be difficult – the revision becomes the determining factor as to which hardware was used.

First thing is to determine which devices are supported. Start with the release documents for the operating system and look for supported hardware. Another place to look is the man pages (or other documentation) for the drivers. Keep the list of specific hardware handy, on another screen or printed out.

Then, look for the device (or devices) at your chosen store. Write down what you find, even if it isn’t listed (and even if it is). Then look up the device on the Internet using your desired search engine. Pay attention to mailing list threads and watch what sort of trouble people had (or didn’t have). The mailing list threads should also help you identify the hardware sources used in otherwise unidentified products, and also will keep you up to date on people’s experiences.

Once you have a product chosen, given few problems on mailing lists and a well-supported and identified hardware chip set, then buy it. However, for best results, make sure there is a good return policy in case it doesn’t work – otherwise, you are taking a chance (albeit a very small one if you’ve done your homework).

I’ve gone through this with several wireless cards under FreeBSD. The first was the Netgear MA401 (researched as given here) – worked flawlessly until it was smushed. The second I received as a bonus with my laptop purchase was a Zonet 1502 (definitely a mistake, but it came with the laptop). I’m sure the Zonet works fine under Windows (and probably OpenBSD: they reverse engineered the driver). Currently, I’ve added a TP-Link TL-WN610G (again researched as described here) – also working flawlessly.

This isn’t just good practice for wireless cards, though – networking cards, mice, video – all benefit from this research. Even laptops: when I bought my laptop, I researched the two brands that were available (for sale used at my favorite local used computer store) and found that one had lots of difficulties and the other did not. Guess which one I bought?

Running Linux/UNIX under VMware Server 1.0

I have the distinct pleasure of having tried a number of systems under VMware Server, including OpenSUSE 10.3, Kubuntu 7.10, OpenBSD, and Solaris Express Developer Edition.  All work quite nicely.

There is one caveat – this environment uses a dual-monitor setup for Windows, and if the emulator autodetects the desktop size it expands to something approximating the two monitors put together.  The emulated environment works just fine (usually) with this screen, but it can’t be used in full-screen mode (since that goes to one screen only).

In that line of video mishaps, Solaris detected the video but only wants to allow 1024×768 (I’ve 1280×1024 here).  Whatever.

I also did not try OpenBSD as a desktop environment – I’ve actually yet to really put it through its paces that way (although I did set up OpenBSD 3.0/Mac68k with WindowMaker a while back….).

Which one do I like the most?  Currently I find myself looking toward OpenSUSE 10.3 more and more – and loving to use it.  The new KDE menu is a pleasure to use, and I love the immense selection of RPMs (and I do like RPM as it is).

The fact that they split up the KDE RPMs seems ghastly to me – too many things to choose.  For example, KDE Office is available in all its little bits – as is KDE Toys, KDE Games, and whatever else.  Nicer just to choose to install KDE Toys or not… I’m not sure whether I like having KDE 3 as a base with all of the KDE 4 applications available – but it seems to work alright.

I’d like to install BeleniX next, but they’ve not updated their system yet – the last hard disk install was buggy. I’m waiting eagerly….

What’s Your Favorite Operating System?

I was asked this question recently. Everyone likely has an answer: Red Hat Linux, Debian GNU/Linux, Solaris… My answer surprised the questioner: UNIX and UNIX-workalikes. This includes FreeBSD… and Red Hat… and Solaris… and HP-UX… and AIX… and so forth. When I first became interested in UNIX, not one of the aforementioned products existed. First UNIX system I got my hands on briefly was Eunice (look it up 🙂 and the next (a few years later) was Microport System V (for the IBM AT).

Perhaps you might think Solaris is better than Linux – or NetBSD is better than OpenBSD. I suggest it doesn’t matter. Each UNIX (or UNIX-like) environment has its pluses and minuses. Individual choices are personal and enterprise choices are practical – in either case, which is truly better doesn’t matter.

If your enterprise is using Oracle, for example, the choice of which UNIX system you use is dramatically reduced: which system will Oracle support? You won’t be using Oracle on FreeBSD unless you forgo the Oracle maintenance contract. Choices like this continually appear in the enterprise. Perhaps the new version of Red Hat Enterprise Linux has everything you want – but Oracle doesn’t yet support that version.

Alternately, which system you use for your own desktop is a personal choice. Which one is “better” is which one feels better to you. UNIX is, at its heart, unified – that is, it is a single environment – but it provides a wide choice of user interfaces, user programs, and even technical items such as filesystems and virtual memory management schemes. Use whichever one seems better.

What do I use on my personal desktop? Mac OS X. However, in line with the ideas posited above, I’ve just expanded my “desktop” with Synergy, linking my “other” desktop (first Fedora Core 5, now BeleniX with OpenSolaris core) to my Mac OS X desktop. More about Synergy later.

So next time someone tells you what their favorite operating environment is – why not find out what it is they’re so excited about? You might find something exciting yourself.