MySQL How To Create a User If They Do Not Already Exist

It is kind of hard to find the answer to how you create a user in mysql if they do not exist. The reason is probably because they way it is done is completely odd. Instead of create user, you use grant. Who made this stuff up? SQL is so oddball sometimes. Anyway, here it is:


GRANT ALL PRIVILEGES ON database_name.*
TO 'user'@'%' IDENTIFIED BY 'password'
WITH GRANT OPTION;

How to Reset the MySQL Server Root Password

The easiest way to reset the MySQL root password is stop the MySQL server daemon

service mysql stop

Restart the daemon manually

mysqld --skip-grant-tables

Connect to it using the mysql client and run the SQL:

update mysql.user set password=PASSWORD('changeme') where user='root';

How to Determine the Source of a Debian Package

Sometimes when you are doing an apt-get install, you have no idea who is providing the package you are installing. You may also get an unexpected version because there are multiple providers of a package in your source repository list. The command to determine the source of a debian package is apt-cache policy <package-name>.  For example:

 

terry@brat:~$ apt-cache policy automake
automake:
  Installed: 1:1.11.1-1ubuntu1
  Candidate: 1:1.11.1-1ubuntu1
  Version table:
 *** 1:1.11.1-1ubuntu1 0
        500 http://us.archive.ubuntu.com/ubuntu/ oneiric/main amd64 Packages
        100 /var/lib/dpkg/status
terry@brat:~$

Chef: Run list contains invalid items: no versions match the constraints on cookbooks

Every time I get this message I start grepping through roles and cookbooks to find where the constraint is on the cookbook.  It isn’t in the role or cookbook, it is in the environment.  The environment contains a “cookbook_versions” section that is verified before the cookbooks are run.

Juniper VPN on Ubuntu 11.10 64 bit

I just went the hassle of connecting to a Juniper VPN on Ubuntu 11.10 with a 64 bit operating system. It turns out I was getting “Failed to load the ncui library.” because the 64 bit Java would not link with the 32 bit library. When I loaded the 32bit Java

sudo apt-get install ia32-sun-java6-bin

I also ran the update-alternatives on java

sudo update-alternatives --config java

Set the environment variable:

export JDK_HOME=/usr/lib/jvm/ia32-java-6-sun

I cleared my JAVA_HOME variable which was pointing to the 64 bit version, although it isn’t clear to me that mattered. Relavent links:

  • http://www.rz.uni-karlsruhe.de/~iwr91/juniper/
  • https://launchpad.net/~ferramroberto/+archive/java

Another couple of options I haven’t investiaged:

  • http://code.google.com/p/juniper-sslvpn-nojava/updates/list
  • http://mad-scientist.us/juniper.html

Oracle/Sun Java on Ubuntu

Ubuntu 11.10 does not offer Oracle’s Java because OpenJDK supposedly replaces it.  My guess is the OpenJDK “properly” implements Java such that it doesn’t work with any problem.  I find it highly annoying, most programs don’t run with it.

You can install Oracle’s Java 6.2 from this PPA (Private Package Archive).
Please see ppa:ferramroberto/java… 

sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-cache search sun-java6
sudo apt-get install –reinstall sun-java6-jre sun-java6-plugin sun-java6-fonts

Then set java-6-sun as default. Choose java-6-sun/jre/ from the list. This step is important:
sudo update-alternatives –config java

This command does it directly without asking:
sudo update-alternatives –set java /usr/lib/jvm/java-6-sun/jre/bin/java

Roses and Thorns: Java/Spring/Wicket/Hibernate Union Membership Management

It is hard not to focus on the negatives on these projects although most of them went pretty well. Sometimes the thorns are actually the roses because we overcame some problem. The union member management application we worked on is a good example of this.

Our thorn on this project was automating functional tests. It is hard to get good code coverage with Java Spring they way you can with unit tests in RoR. Automating functional tests are also extremely difficult with Wicket because Wicket generates ids for all the HTML elements and they change, so they are impossible to target. What we ended up doing was adding name attribute to every element we wanted to target. Targeting by name is a little more difficult, but it worked well for automating these tests.

Roses and Thorns: Flex Speech Therapy Project

Our first and only Flex project was a speech therapy application. The customer had an application written in C++, but it didn’t work very well. We salvaged the portion of the C++ code that read and analyzed the speech data from the microphone and rewrote everything else. There were also a lot of features that we added.

Flex was a good choice for this application because the long range goal was to make the project complete web based, but the first phase was for a package that could be installed on a therapists computer. Flex was easy to learn and it easily followed the Model/View/Controller pattern. We kept the C++ microphone reader because it would of taken time to develop the code in Flex and as I recall Flex didn’t support reading from the microphone very well at the time.

The thorns for this project were customer management. We weren’t involved in customer management on the job, but I kind of doubt we would of done a better job. The customers were not technical and one customer didn’t look at anything until the very end and then requested all sorts of change. We were delivering updates at the completion of iterations and it would of really helped if feedback was earlier. The final product really enforced too much procedure that should of been enforced by the therapist.

Another thorn for the project was testing Flex was not as easy at testing RoR projects.

Roses and Thorns: Java/Spring/Wicket/Hibernate Device Manager

The next project we worked on was a device manager written in Java/Spring/Wicket/Hibernate. Actually, there were a couple projects for this customer, but the general architecture was the same. The applications run in the cloud and use Terracotta to share information between instances. There were several devices supported, but generally, the devices were Zigbee gateways and the gateway controlled other devices. These devices might be in a smart home or installed in an industrial environment to monitor equipment or resources.

The roses here were the interesting technology used. Java/Spring/Wicket/Hibernate and Zigbee devices are interesting. Were were also implementing SMS and satellite interfaces for devices that were not connected to the Internet, so those were fun problems to solve.

Now I think Java is a great language and I have a lot more enthusiasm for it than Ruby as a language, but Java model/view controller (MVC) is nothing to RoR MVC. There is no natural enforcement for controllers and I don’t think hibernate lends itself to putting logic in the models as it does in RoR. Part of the problem was the application started before Hibernate annotations, so they used XML and generated POJOs. Terracotta also provided a new set of problems for us. It is all about learning how to set up Terracotta, but you think everything is great because your unit tests pass and your functional tests run fine, but when you spin up multiple instances of servers, things blow up.

Roses and Thorns: Various RoR Applications

The next bunch of Rails applications we worked on were for a Video Relay Service (VRS) provider. VRS providers have a call center where deaf or hard of hearing people call in to the call center via a video phone call and the operator will read the sign language and speak the message to the person the customer needs to communicate with. The operator translates in both directions. We did several RoR projects for this company and they were using an interesting architecture which was ahead of the time.

The first project we did was a couple of RoR applications to read and update configuration information from various video phones. The next RoR application updated 911 information for their customers so that emergency personnel would be dispatched to the correct address. The next application read and updated an ENUM database so that calls from a customer of one VRS provider could be routed to a customer for another VRS provider. All of this work was very interesting and generally a Rose as was their architecture. Each one of these little applications would run on its own VMWare image and they were doing this before cloud computing really got popular. It was nice in that they ran a lot of little easy to understand applications that were loosely coupled.

I really can’t say there were any thorns to working on these projects.