Your only hope in this scenario is to have the PROCESS privilege.
The SUPER privilege allows you to kill processes. Naturally, you don't want that. On the other hand, the PROCESS privilege allows you to see the processlist.
According to the MySQL Documentation on the PROCESS Privilege
The PROCESS privilege pertains to display of information about the
threads executing within the server (that is, information about the
statements being executed by sessions). The privilege enables use of
SHOW PROCESSLIST or mysqladmin processlist to see threads belonging to
other accounts; you can always see your own threads.
OK, Big Deal. The PROCESS Privilege lets you see the Process List. How does that help?
You can quickly detect a mysqldump in progress when you run SHOW PROCESSLIST;
and see a pattern like this in the Info field:
SELECT /*!40001 SQL_NO_CACHE */ * FROM
If you have the PROCESS Privilege and are running MySQL 5.1+, you can run this query:
select COUNT(1) mysqldumpThreads
from information_schema.processlist
where info like 'SELECT /*!40001 SQL_NO_CACHE */%';
Here is a sample output:
mysql> select COUNT(1) mysqldumpThreads
-> from information_schema.processlist
-> where info like 'SELECT /*!40001 SQL_NO_CACHE */%';
+------------------+
| mysqldumpThreads |
+------------------+
| 1 |
+------------------+
1 row in set (0.00 sec)
All you need to do is query for that number. If you get a nonzero, mysqldump must be running.
Give it a Try !!!
The mysqldump utility can dump the following ways from a MySQL Instance:
- All Databases
- One Whole Database
- Part of a Database
- It is possible to mysqldump a space-separated list of tables from one Database
- One Whole Table
- It is not possible to mysqldump a table from one Database and a table from another
- Part of a Table Using
--where
Option
- Stored Procedures
- Schema Only
- Data Only
You cannot mysqldump two tables from two different schema. You must script the tables you want dumps one at a time.
Here is a script to dump every table from a MySQL Instance into separate files
MYSQL_USER=root
MYSQL_PASS=rootpass
MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS}"
SQL="SELECT CONCAT(table_schema,'.',table_name) FROM information_schema.tables"
SQL="${SQL} WHERE table_schema NOT IN ('information_schema','mysql')"
mysql ${MYSQL_CONN} -ANe"${SQL}" > /tmp/ListOfTables.txt
COMMIT_COUNT=0
COMMIT_LIMIT=10
for DBTB in `cat /tmp/ListOfTables.txt`
do
DB=`echo ${DBTB} | sed 's/\./ /g' | awk '{print $1}'`
TB=`echo ${DBTB} | sed 's/\./ /g' | awk '{print $2}'`
mysqldump ${MYSQL_CONN} --hex-blob --triggers ${DB} ${TB} > ${DB}_${TB}.sql &
(( COMMIT_COUNT++ ))
if [ ${COMMIT_COUNT} -eq ${COMMIT_LIMIT} ]
then
COMMIT_COUNT=0
wait
fi
done
if [ ${COMMIT_COUNT} -gt 0 ]
then
wait
fi
In your case, you can create the /tmp/ListOfTables.txt file manually. In order to inject use dbname
, just create the dump file with the use dbname
as the first line. Then, append the output of mysqldump to it. Keep in mind that each table is described as dbname.tablename:
rm -f /tmp/ListOfTables.txt
echo "company.loadme" >> /tmp/ListOfTables.txt
echo "new_company.newload" >> /tmp/ListOfTables.txt
MYSQL_USER=root
MYSQL_PASS=rootpass
MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS}"
COMMIT_COUNT=0
COMMIT_LIMIT=10
for DBTB in `cat /tmp/ListOfTables.txt`
do
DB=`echo ${DBTB} | sed 's/\./ /g' | awk '{print $1}'`
TB=`echo ${DBTB} | sed 's/\./ /g' | awk '{print $2}'`
echo "use ${DB}" > ${DB}_${TB}.sql
mysqldump ${MYSQL_CONN} --hex-blob --triggers ${DB} ${TB} >> ${DB}_${TB}.sql &
(( COMMIT_COUNT++ ))
if [ ${COMMIT_COUNT} -eq ${COMMIT_LIMIT} ]
then
COMMIT_COUNT=0
wait
fi
done
if [ ${COMMIT_COUNT} -gt 0 ]
then
wait
fi
Give it a Try !!!
Best Answer
The documentation is not as clear as it should be, but I would say no, mysqlhotcopy does not block SELECT queries.
Here is why
REASON #1 : MySQL Docs on 'mysqlhotcopy'
REASON #2 : MySQL Docs on 'Lock Tables' Restrictions
In summary, since mysqlhotcopy launches
LOCK TABLES
,SELECT
queries are evidently still allowed.