//看看用户
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
//建立数据库,创建用户,分配权限
CREATE DATABASE javaer DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
create USER 'admin'@'%' IDENTIFIED BY 'rtretw';
create USER 'admin'@'localhost' IDENTIFIED BY 'rtretw';
GRANT ALL ON javaer.* TO 'admin'@'%';
GRANT ALL ON javaer.* TO 'admin'@'localhost';
//分权限
grant select,create,drop,update,alter on *.* to 'admin'@'localhost';
flush privileges;//刷新权限 使msyql权限立即生效
mysql导出命令
mysqldump --default-character-set=utf8 -u admin -p javaer > /backup/51.sql
导出数据的时候,遇到sock错误
[root@localhost ~]# mysqldump --default-character-set=utf8 --sock=/opt/lampp/var/mysql/mysql.sock -u admin -p javaer > /backup/51.sql
mysqldump --default-character-set=utf8 --sock=/opt/lampp/var/mysql/mysql.sock -u admin -p jz_list > /backup/jz.sql
datadir=/var/lib/mysql
关闭mysql
把var/lib/mysql 的东西移动到 /backup/mysql 下
创建软连接
ln -s /backup/mysql /var/lib/mysql
重启动msyql
2020.05.28 补充
强大的MYSQL导出忽略功能,我忽略一个表
mysqldump --ignore-table=crm.fis_crm --default-character-set=utf8 -u urldb -p crm > /test/crm.sql
强大的MYSQL导出忽略功能,我忽略多个表
mysqldump --ignore-table=crm.fis_crm --ignore-table=crm.fis_cash --default-character-set=utf8 -u urldb -p crm > /test/crm.sql