Showing entries 6761 to 6770 of 44037
« 10 Newer Entries | 10 Older Entries »
Locking USER Accounts in MySQL


Locking User Accounts in MySQL


For SOX Compliance when an employee, contractor, or vendor leaves your company their account needs to be locked, expired, or removed.  Some of these people may return, and their Account may have many complicated permissions.  In these cases, it would be better to “Lock” their Account while they are no longer doing business with your company. 
However, MySQL does not have the ability to “Lock” or “Expire” a User Account.   The following is a simple procedure to “Lock” and “Unlock” a MySQL Account.


Typically, the one-way encrypted hash value of a users password is stored in a password field  in an user account table.  MySQL supports three builtin one-way hashed functions, PASSWORD(), MD5() and SHA1().  It is recommended not to directly use the PASSWORD() function. Reason, is that prior to PHP 4.1 version, the …

[Read more]
Kill All Users in MySQL


MySQL – Script to Kill A User Session


I googled around and found some code that could be used with a few tweaks to kill all users EXCEPT the User(s) you specify.


#vi kill_all_users.sh

#!/bin/bash

connections=$(mysql -h$1 -u$2 -p$3 -e "SHOW PROCESSLIST" |grep -v wmayall| grep -v Id | grep -v root|awk '{print $1}' )

for id in $connections

do

    mysql -h$1 -u$2 -p$3 -e "KILL $id"

done


#chmod 700 kill_all_users.sh


The syntax is:


./kill_all_users.sh  –host –user –password:


Below is an example:


./kill_all_users.sh localhost root my_password


The grep –v excludes the User you do NOT want to kill their session.  
If the User is connected through ODBC, a new …

[Read more]
MySQL Replication - Master - Slave ( One Way Replication)


How to Setup MySQL Replication
Configure the Master Database :
First you will need to configure the my.cnf file.  The my.cnf file is not located in the same place on all servers, so you should use the ps command to list how mysql was started.
[root@hostname repl_setup]$ ps -ef | grep mysql
mysql 6290 1 0 May18 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/apps/mysql/my.cnf --pid-file=/apps/mysql/mysql.pidmysql 6318 6290 0 May18 ? 00:48:49 /usr/sbin/mysqld --defaults-file=/apps/mysql/my.cnf --basedir=/usr --datadir=/apps/mysql --pid-file=/apps/mysql/mysql.pid --skip-external-locking --port=3300 --socket=/apps/mysql/mysql.sockmysql 6473 1 0 May18 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/apps2/mysql/my.cnf --pid-file=/apps2/mysql/mysql.pidmysql 6501 6473 0 May18 ? 00:19:18 /usr/sbin/mysqld --defaults-file=/apps2/mysql/my.cnf --basedir=/usr --datadir=/apps2/mysql …

[Read more]
MySQL when Optimize Fails



MySQL – When an Optimize Fails
When using the MyISAM engine, you may need to run an “optimize” to regain space and increase performance.  What do you need to know BEFORE you start the “optimize” command.


The first thing to know is the “optimize” creates a Temporary file in the database datadir, (see mr.TMD).  The problem is there is only 16GB of free space with the mr.MYD and mr.MYI are almost 40GB.  There is one more thing you need to know.  MySQL uses tmpdir at the end of the “optimize” which can be a problem if there is not enough space.


SERVER1:/db/mysql/data/stats>ls -lt kh*                                                                   -rw-rw---- 1 pm pmapp 18163175424 Mar 23 …

[Read more]
Script I use to isolate MySQL Performance Problems


Scripts I Use to Isolate MySQL Performance Problems

#!/bin/sh
#./run_iostat.sh > REPORT.doc &
x=1
while [ $x -le 60 ]
do
echo "START RUN TIME"
date
/usr/bin/iostat -d 2 6
date
  x=$(( $x + 1 ))
date
echo "END RUN TIME"
sleep 60
done


#!/bin/sh
#./run_mysqlreport_sleep60.sh > REPORT.doc &
x=1
while [ $x -le 60 ]
do
echo "START TIME"
date
mysqlreport –user USER --password PASSWD --host HOST --port 3306
  x=$(( $x + 1 ))
echo "END DATE"
sleep 60
done


#!/bin/sh
#./run_iostat.sh > VMSTAT_REPORT.doc &
x=1
while [ $x -le 60 ]
do
echo "START TIME"
date
/usr/bin/vmstat
/usr/bin/vmstat -d
  x=$(( $x + 1 ))
echo "END DATE" …

[Read more]
Sizing MySQL on TEMP Tables

=================================================MySQL Configuration Changes

 =================================================This document is intended to explain how MySQL creates Temporary Tables and how to tune the MySQL Configuration file to improve query performance for Power Users.  MySQL will create a Temporary Table when a user issues a Group By or Order By command.  
MySQL will first create the Temporary Table in Memory, if the query exceeds the value of certain parameters in the my.cnf file, MySQL will use the MyISAM Storage Engine creating *.MYI and *.MYD files in the /tmp directory.  When MySQL has to create the *.MYI and *.MTD files the query performance will be slower than creating the Temporary Tables in Memory.


I created a Test on dl4dev to illustrate how MySQL creates Temporary Tables and how changing the MySQL Configuration file will improve performance.  My plan was …

[Read more]
MySQL 8 Invisible Indexes

MySQL 8 features invisible indexes. But what good is an index if you can see it? br>Is It Really InvisibleYou probably know by now that indexes can really speed up data searches. And many of you have mastered the use of EXPLAIN to see if the optimizer is using an index for your query. Which means you should know that sometimes for some queries an index does not help.


mysql> CREATE TABLE t2 (
-> i INT NOT NULL,
-> j INT NOT NULL,
-> UNIQUE j_idx (j)
-> ) ENGINE = InnoDB;

Query OK, 0 rows affected (0.01 sec)

mysql> insert into t2 values (1,2),(3,4),(5,6),(7,8);
Query OK, 4 rows affected (0.00 sec)

mysql> explain select j from t2 where j>2;
+----+-------------+-------+------------+-------+---------------+-------+---------+------+------+----------+--------------------------+
| id | select_type | table | …
[Read more]
Percona Server 5.6.35-80.0 is Now Available

Percona announces the release of Percona Server 5.6.35-80.0 on February 8, 2017. Download the latest version from the Percona web site or the Percona Software Repositories.

Based on MySQL 5.6.35, and including all the bug fixes in it, Percona Server 5.6.35-80.0 is the current GA release in the Percona Server 5.6 series. Percona Server is open-source and free – this is the latest release of our …

[Read more]
MySQL Server log Maintenance

As a part database administration, DBA has to take care of sub-components of database like server logs and has to plan for maintenance activity for these components regularly.

MySQL has various types of log i.e binary log, error log, slow query log, general log for different purposes. And after certain time these logs will grow and you will start seeing issues like low disk space, a large number of logs etc.

MySQL allows you to flush logs using flush logs command, next “How to rotate and clean up old MySQL logs? ”

Linux has a utility called “logrotate” , using logrotate we can implement log rotation for MySQL server logs.

Binary logs: This one is critical if you have replication setup, By enabling  expire_logs_days mysql variable you can manage …

[Read more]
MySQL super_read_only Bugs

This blog we describe an issue with MySQL 5.7’s super_read_only feature when used alongside with GTID in chained slave instances.

Background

In MySQL 5.7.5 and onward introduced the gtid_executed table in the MySQL database to store every GTID. This allows slave instances to use the GTID feature regardless whether the binlog option is set or not. Here is an example of the rows in the gtid_executed table:

mysql> SELECT * FROM mysql.gtid_executed;
+--------------------------------------+----------------+--------------+
| source_uuid                          | interval_start | interval_end | …
[Read more]
Showing entries 6761 to 6770 of 44037
« 10 Newer Entries | 10 Older Entries »