Skip to content

https://www.cnblogs.com/elsons/p/15763248.html

查看主从

maxctrl list servers

查看运行进程

top

top -Hp pid

// 查找到具体的mysql 进程id
pidof mysqld

mysql 慢查询日志和数据文件路径

/var/lib/mysql

清空慢查询日志,并恢复 https://blog.csdn.net/weixin_41275260/article/details/125461408

mysql group by 字段或者非聚合字段是否可以添加到select 后

查看磁盘文件大小

  • du -sh *

查看linux 磁盘分区

  • df -h

mysql文件存储位置

MariaDB [(none)]> show variables like '%%datadir'; +---------------+-----------------+ | Variable_name | Value | +---------------+-----------------+ | datadir | /var/lib/mysql/ | +---------------+-----------------+ 1 row in set (0.001 sec)

查看事务 查看锁

主从停止https://blog.csdn.net/weixin_34981046/article/details/113127203

mysql 全量备份

mysqldump -uroot -p123456 db1 > db1.sql

/usr/share/mysql/policy/apparmor

/etc/my.cnf.d

create user 'root'@'%' identified with mysql_native_password by 'sunlight2010';

ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' BY 'M9y512!';

create user 'root'@'%' identified by 'sunlight2010'; update mysql.user set plugin='mysql_native_password' where

grant all privileges on . to 'root'@'%';

grant all privileges on . to 'root'@'localhost';

// 新建一个用户 CREATE USER 'course'@'localhost' IDENTIFIED BY '123456';

// 并将数据库添加到该用户下 grant all privileges on . to 'course'@'localhost';

flush privileges;

mysql最大链接数

/etc/my.cnf.d

systemctl daemon-reload

systemctl restart mysqld.service

mysql count 汇总统计