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


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

Your email address will not be published. Required fields are marked *

*

*

  

About Me

静水流深,水滴石穿