2020-12-29 MySQL基本语句

MySQL登录:
mysql -u root -p
创建新用户:
create user 'blog'@'localhost' identified by 'koM5gTR'; 赋予用户对数据库的访问权限: grant all privileges on `blog`.* to 'blog'@'localhost' identified by 'koM5gTR';
刷新权限:
flush privileges;
直接修改密码:
set password for blog@localhost = password('sz1nQLGY');
alter user blog@localhost identified by 'sz1nQLGY';
间接修改密码:
use mysql;
select host,user,plugin,authentication_string from user;
update user set password=password('sz1nQLGY') where user='blog' and host='localhost';
flush privileges;
创建可从外部访问的MySQL用户并赋予访问权限:
create user 'bingquan'@'%' identified by 'koMaFiZL!8bO'; grant all privileges on `zhengxin`.* to 'bingquan'@'%' identified by 'koMaFiZL!8bO';
退出:
exit
MySQL导出SQL文件:
mysqldump -u blog -p blog > blog.sql
mysqldump -u blog -p blog users> blog_users.sql

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容