java多线程    Java入门    vsftp    ftp    linux配置    centos    FRP教程    HBase    Html5缓存    webp    zabbix    分布式    neo4j图数据库    

mysql底层命令,用户分配,权限,导出导入数据库


//看看用户
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


This entry was posted in Linux and tagged . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/mysql-import-export/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力.

Leave a Reply