1.更改远程的root密码

mysqladmin -h ip -uroot -p123456 password 密码

如果出现'Access denied for user 'root'@'ip' (using password: YES)'

那么说明权限不够,远程主机不允许除了localhost以外其他登录。

这个时候就要把查看下root主机权限

wKiom1TLPn_ArjfRAAEoYcU2fPQ404.jpg

会看到主机只允许本机登录,不允许远程的主机登录,

这个时候就要修改权限,

show grants for 'root'@'%';

wKioL1TLP8fTGiCTAAEp3eGtJJc383.jpg

可以看到root现在权限不仅仅在本机了。

然后在别的主机上进行root远程登录

wKiom1TLP3_gzIvGAAGfpAl5qTY360.jpg

然后远程主机密码修改

mysqladmin -h ip -uroot -p123456 password 密码 就可以修改远程root登录密码

而且远程登录主机的密码 是远程root 而不是你要登录的远程主机它自己本身的密码,两者不相同。

新手的我刚开始也没搞清楚。

6.ps aux |grep mysqld

可以查看文件运行位置和数据所在位置wKiom1TLQdrivuHtAAGvZuaMFhQ647.jpg


7.删除用户在数据库的权限

revoke all on 库名.* from '用户'@'%' identified by '密码';


8.远程主机备份数据库

mysqldump -h 192.168.121.13 -uroot -pyzg1314520 test>test.sql(要有test数据库)


数据库导出成文本备份

mysqldump -uroot -pyzg1314520 --databases zabbix > zabbix.test


8.修改mysql空密码

mysql> update mysql.user set password=PASSWORD('新密码') where User='root';

    mysql> flush privileges;

    mysql> exit



恢复

mysqldump -h 192.168.121.13 -uroot -pyzg1314520 test<test.sql


9.给用户权限

grant all on 用户.* to '用户'@'%' identified by '密码';


10.进入information_schema,查看所有数据库大小

use information_schema;

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;


11.查看指定数据库大小

use information_schema;

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='数据库名';


12.查看指定数据库的某个表的大小

use information_schema;

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='home' and table_name='表名';