Jump to Navigation

Recently created

MySQL: Stored programs quick reference

This is a quick reference guide for writing MySQL stored programs. It is assumed you have some experience with similar programming languages (for example, Oracle PL/SQL). This has been written for MySQL 5.6.

Defining stored programs

There are four kinds of stored programs:

  • Procedures
  • Functions
  • Triggers
  • Events

Functions can be called from SQL queries.

MySQL: Clean shutdown

You want to shutdown MySQL as cleanly as possible, perhaps because you want to create backups or want to do an upgrade.

Assumptions

  • You are running MySQL 5.5 or later

Procedure

If possible, stop all incoming connections (for example, from application servers).

On a slave or replication server, stop the I/O thread (which grabs updates from the master) and wait for the SQL thread to process all:

MySQL: Setting up replication

This is a simple guide to setting up replication between MySQL servers.

Assumptions

  • You are using MySQL 5.5 or later;
  • The master server is currently not being used and is not yet configured to use binlogs;
  • The slave server contains a perfect copy of the master server databases.

Procedure

On the master side, make sure the following statements are included in the /etc/my.cnf file:

MySQL: Identify invalid views

Symptoms

When querying a MySQL view, or when dumping a MySQL database, you get an error including the following text:

View ... references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

A MySQL dump stops at that point.

You want to identify those views that return this error through a database query.

Pages

Subscribe to Recently created


by Dr. Radut