1. Allow mysql remote connection
as in 4
3. View character set settings
show variables like 'character%';
4. Database
grant grant all on *.* to 'root'@'%' identified by 'Reset123QWE';
flush privileges;
grant permission name (all permissions are used) on library name (*all). Table name (*all) to 'username to be authorized'@'%'(% means all IPs, you can only add one IP)
grant USAGE on cms.* to testread@'%' identified by '123456';
grant select on cms.* to testread@'%' identified by '123456';
grant all on test.* to 'testread'@'%' identified by '123456';
5. Modify mysql password
>use mysql
>update user set password=PASSWORD('Reset123QWE') where user='root'
>flush privileges
6. Look at the current default storage engine of your mysql:
mysql> show variables like '%storage_engine%';
7. See what storage engine your mysql now provides:
mysql> show engines;
8. View the current isolation level
SELECT @@tx_isolation;
9. Set the global transaction isolation level
set global transaction isolation level read committed;
set session transaction isolation level read committed;
10. Export mysql
mysqldump -uroot -pReset123QWE --all-databases > cms.sql
11. View the current connection number configuration
show variables like 'max_connections';
12. Set the maximum connection Number
set global max_connections=1000;
13. Modify my.cnf, configure the maximum number of connections
max_connections=2000
14. Get the date of the previous day
select date_sub(curdate(), interval 1 day);
15. Query the date of a certain day
SELECT * FROM tb_task_info_20160301 WHERE DATE(create_time) = '2016-03-01' ORDER BY create_time DESC
16. Query the number of records of all tables in a library
select table_name,table_rows from tables order by TABLE_ROWS desc limit 0,100
17. Forgot the password, start mysqld in another way
--defaults-file="C:\mysql-5.5.39-win32\my.ini" --console --skip-grant-tables
18. Group statistics having
SELECT domain, COUNT(id) c FROM tb_tencent_cfg_domain GROUP BY domain HAVING(c)>1
19. Filter delete
DELETE FROM tb_tencent_cfg_domain WHERE (`domain`, `id`) IN (
SELECT v.domain, v.id FROM
(SELECT domain , MAX(id) id FROM tb_tencent_cfg_domain GROUP BY domain HAVING COUNT(id)>1 ) v
) ;
20. Check if sql has changed
WHERE id = #id#
and ifnull(date_format(modify_time,'%Y-%m-%d %H:%i:%s'),'') = ifnull(#modifyTime#,'');
Understand mysql_ commonly used classic sql
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326193416&siteId=291194637
Recommended
Ranking