Management
Connect from shell
mysql -u root -h giipdb.mysql.com -p -P 3306
-u
: user-p
: ask password-h
: host-P
: Port
show running SQL
show processlist;
show full processlist \G
Cursor
Binlog(Binary Log)
Start option
stop
mysqladmin -u root -p shutdown
Run from sql file
Tuning
Innodb
- Check tuning point using mysqltuner
- You can tune easy by suggestion on mysqltuner
$ wget https://github.com/major/MySQLTuner-perl/zipball/master
$ unzip master
$ cd master
$ ./mysqltuner.pl
innodb storage engine
SQL relative innodb buffer pool size
show innodb engine information
SHOW ENGINE INNODB STATUS\G
Query Cache Tuning
-- Configuration
SHOW VARIABLES LIKE '%query_cache%';
-- Usages
SHOW STATUS LIKE 'Qcache%';
tuning writings
Information
- Characterset vs collation
- collation_connection, collation_server
- character_server, character_database
- https://atsuizo.hatenadiary.jp/entry/2016/08/22/090000
Trouble shooting
- extend timeout from MySQL Workbench client
InnoDB: Doing recovery: scanned up to log sequence number 2938498040110
- If you forgot root password...
- https://liginc.co.jp/web/programming/mysql/87393
mysqld_safe --skip-grant-tables &
as Run with no pass
- Can not effect grant command
- resolve to recreate user using grant command
Useful SQL
- Update join
UPDATE users a
LEFT JOIN userlog b
ON a.userid = b.userid
SET a.point = a.point + 100
WHERE b.loginstatus = 1;
- insert select on duplicate key update
- it have to make primary key. Compare with TABLEA and TABLEB by primary key.
insert into TABLEA (FIELDA01, FIELDA02)
select FIELDB01, FIELDB02
from TABLEB
where FIELDB03 = 'formerge'
on duplicate key update FIELDA02 = FIELDB04
Functions
CAST() - converting various datetime format using CAST
DATE_FORMAT()
Shell
- do not ask password when running cron job or shell batch
コメント
コメントを投稿