Showing entries 21 to 26
« 10 Newer Entries
Displaying posts with tag: mysql client (reset)
Use of DECLARE and SET in MySQL stored program

DELIMITER $$                    -- Change the delimiter

DROP PROCEDURE IF EXISTS demo$$ -- Remove if previously exists
CREATE PROCEDURE demo()         -- Create Stored Procedure
BEGIN                           -- Start of definition
    DECLARE my_int INT;         -- Declare variables
    DECLARE my_big_int BIGINT;
    DECLARE my_text TEXT;

    DECLARE my_name VARCHAR(30) -- Declare variables with 
        DEFAULT 'Rookie Dev';   -- default value set

    SET my_int = 20;            -- Set variables to values

[Read more]
How to execute mysql query from a file in your mysql client terminal?

Being a terminal fan myself, I usually find myself running queries in the mysql client instead of a UI interface as it is much faster. You get to see the results instantaneously.

One thing which is pretty tedious is editing a big query again after once running it as the whole multi-line formatted query now appears on a single line, thus reducing its readability.

But no problems, you can edit your query from a file and run the file from your mysql client terminal as many times as you want with as many edits.

To do so, follow the below steps:

1. Open your terminal and cd into the folder you want to store our sample mysql file. Then save your query in a sample file called my_query.sql

$ cd /path/to/folder
$ vim my_query.sql

Save a sample query like:

SELECT * FROM employees
WHERE type LIKE …

[Read more]
Correctly setting your mysql prompt using sudo

If you run multiple MySQL environments on multiple servers it’s a good habit to set your MySQL prompt to double check which server you are on.
however, using the MYSQL_PS1 environment variable I found this does not work under sudo (the normal way people run sudo).

I.e., the following syntax’s work.

$ mysql
$ sudo su - -c mysql
$ sudo su - ; mysql

but the following does not.

$ sudo mysql

The trick is actually to ensure via /etc/sudoers you inherit the MySQL_PS1 environment variable.

echo "export MYSQL_PS1="`hostname` [d]> "" | sudo tee /etc/profile.d/mysql.sh
echo 'Defaults    env_keep += "MYSQL_PS1"' | sudo tee /tmp/mysql
sudo chmod 400 /tmp/mysql
sudo mv /tmp/mysql /etc/sudoers.d
DBA 101: Sometimes forgotten functionality in the MySQL client

The MySQL client has some functionalities some of us never use. Why would you use them and what is the added value of this?

Every DBA and developer has had a moment when he or she needs to connect to a MySQL database using the command line tool. Therefore I’ve written down an explanation of some command line commands you can insert in the CLI, most of them give added value and make your experience with the cli more enjoyable.

prompt

Who has never witnessed the scary feeling of not being connected to the write database when having several terminals open. I do, due to the fact I use the prompt functionality.

mysql >\R Production >
PROMPT set to 'Production > '

Or you can go a bit further and visualise the user, host and active database in:

mysql > \R \u@\h [\d]>
PROMPT set to '\u@\h [\d]>'
root@testbox [test]>

edit

In some …

[Read more]
HoneyMonitor v.1.0.15 released!


We are pleased to announce the release 1.0.15 of HoneyMonitor, our GUI for MySQL™ administration and monitoring.

In this release, available for immediate download, we have fixed some bugs without adding many new features.

We are working to release a RC version as soon as possible.

The following is the list of changes:

- New Features:

  1. new menu entry Auditing / Reports / Edit Report’s Template / Custom Report.

- Improvements:

  1. minor bugs fix and improvements in the Report Designer.

- Bugs Fix:

  1. on Vista™, the Report Designer was losing the connection after …
[Read more]
Step by Step Guide on How to Create a Customized Performance Report using HoneyMonitor

Reading this article you will learn how to create a Customized Performance Report for one of your MySQL™ Servers using HoneyMonitor, a GUI for MySQL™ Server Administration, Monitoring & Performance Tuning.

Contents

  • Introduction
  • Step 1 - Choosing a File Name and Opening the Report Designer
  • Step 2 - Editing the SQL Queries used by the Report
  • Step 3 - Editing the Charts contained in the Report
    • Axis Name
    • Series
  • Step 4 - Other minor changes
  • Step 5 - Previewing our Customized Report
  • Few Considerations and Useful Tips
    • Actual Date Interval
[Read more]
Showing entries 21 to 26
« 10 Newer Entries