Top Nav

Archive | Databases

Move MySQL tmpdir to RAM

1. Create the tmp directory:

2. Set permissions:

3. Determine mysql user id:

4. Edit /etc/fstab and add the following line:

5. Mount the new tmpfs partition:

6. Edit /etc/my.cnf and set location of tmp directory:

7. Restart mysqd

1

Setup Alternate MySQL Instance

To setup an alternate instance of MySQL listening on TCP port 3307 on a RHEL5 server follow these steps.

1. Setup a new MySQL config file.

Add a line like this:

to the “[mysqld]” section.

Edit /etc/my-3307.cnf and change:

to

Change:

to:

Change the following lines:

to:

Change server-id to a unique value:

2. Setup a new service control script.

Edit /etc/init.d/mysqld-3307 and add this line:

directly after:

so that you have:

Next change this function:

to:

Notice that the change is to add “-c $MYCNF” to the call to “my_print_defaults”.

Finally run the following search/replace commands to fixup the program name, add defaults file to mysqld_safe call and set unique pid and subsys files:

3. Setup directories

4. Set service to start on boot

5. Start the new instance:

On the first startup you should see some output like this:

6. Set MySQL root password.

And that’s it. You now have an new instance of MySQL listening on port 3307.

Remember that you must tell the mysql command line utilities where to find the instance. For example:

or

Also keep in mind that by default any .my.cnf file in your home directory will be used. You may have to override settings in the .my.cnf file and explicitly provide the user and password when connecting.

0

MySQL Binary Log Rotation

Came across a handy configuration setting for mysql:

Controls how many days of binary log files should be retained. Very good way to keep the binary logs from over flowing available storage.

0

MySQL Import Problem – Autoincrement

Trying to dump and import a mysql database from an old MySQL 3.x server to a 4.x server. Here’s an exerpt from the dump file:

What’s happening, is when it inserts the first row, it’s
auto-incrementing the key value to 1, so the next row that tries to
import gets a “Duplicate entry ‘1’ for key 1” error.

The solution was to add the following line to the top of your sql dump file:

Later versions of mysql do this automatically.

Problem is the first insert tries to put a 0 into the autoincrement
field. Normal behavior is for the 0 to be converted to the next
available increment which is one. Then the second row fails because
there is already a 1 in the table. The mode setting above tells mysql to
allow the 0 in the auto increment field.

0

Easy MySql Install on RHEL AS4

The RHEL AS4 server had an active RHN membership so installing MySQL server was a quick and easy. Here are the commands:

# up2date –install mysql-server

# /sbin/service mysqld start

# mysqladmin -u root password “my_root_password”

# mysqladmin -u root -h localhost -p password “my_root_password”

The last command will prompt for a password. Enter the value for “my_root_password”.

And that’s all there was to it!

0