mysql

recent posts related to the mysql database

MySQL auto increment - the MySQL auto_increment attribute

MySQL FAQ: How do I define a MySQL auto increment field?

Here's an example of the way I normally create a MySQL auto increment (auto_increment) field:

MySQL foreign key - How to define a foreign key in MySQL

MySQL foreign key FAQ: How do I define a foreign key in MySQL?

Answer: Here's a quick example of how I typically define a foreign key in MySQL.

Diving right into an example, here's the definition for a MySQL database table named nodes that I will link to from a second table:

The MySQL default port is ...

Today I was configuring a MySQL JNDI connection pool on a Glassfish server, when my brain went completely blank, and I couldn't remember what port MySQL listens on by default.

How to create a MySQL database and user account for Drupal

The Drupal installation documentation has a really nice description for how to create a MySQL database (for use with Drupal), so I thought I'd include some of their documentation here, along with some notes from my own recent Drupal and MySQL installation.

Create the MySQL database

The first part of the Drupal installation document refers to creating the MySQL database:

Initial MySQL root user account - how to create

After finishing my latest Drupal installation, I installed a MySQL database on my Linux server using yum, and then my mind went blank -- I couldn't remember how to create the initial MySQL root user (the initial MySQL user account).

Still unable to remember how to do this, I went ahead and started the MySQL server just to make sure it was installed okay, like this:

The MySQL SHOW INDEX command

For a long time I couldn't remember how to show the indexes for a database table with MySQL, but I think it's finally sunk in. Just use the MySQL SHOW INDEX command, like this:

show index from node;

That example can be read as, "Show the indexes from the database table named node". It assumes that you have already selected a database table, so really, a full sequence of commands to show a MySQL database table index looks like this:

Solving the MySQL "can't create/write to file" error message

Two MySQL error messages

Earlier this week I ran into a problem with a website that I tracked down to a MySQL error message that looked like this:

can't create/write to file /var/lib/mysql/foo.bar.baz
Errcode: 23

How to save the output from a MySQL query to a file

I had a problem with this website last Wednesday, and as part of troubleshooting the problem, I need to look at one of the Drupal database tables, specifically the watchdog table. This table had thousands of records in it, and I couldn't find what I needed with SQL SELECT queries, so I finally dug through the MySQL documentation, and found that I could save the output from a SELECT query to a text file.

In this tutorial I'll show you both (a) how to save the results of a MySQL query to a text file, and also (b) how to log your entire MySQL session to a text file.

A Nagios MySQL database design

I recently worked on a project where I wrote a web-based user interface that would let "everyday users" maintain their own Nagios configuration data. After logging in to the web interface, users could modify the Nagios configuration as desired, for instance, when they added new equipment to their network.

Because everything worked out really well, I thought I'd share my Nagios/MySQL database schema here in case it will help anyone else.

How to restore a MySQL database from a backup

Assuming that you've created a MySQL database backup file as shown in my "How to Backup a MySQL database" tutorial, you can use the commands shown here to restore your MySQL database. As mentioned in that article, I strongly recommend that you test your backup file by trying to restore it to another MySQL database server to make sure there are no problems with the file, and the commands shown here can be used for that test as well.

Syndicate content