Mysql基础操作

   日期:2020-11-15     浏览:93    评论:0    
核心提示:数据库必须具有UTF8字符集create database jiradb character set utf8 collate utf8_bin; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on <JIRADB>.* TO '<USERNAME>'@'<JIRA_SERVER_HOSTN...

数据库必须具有UTF8字符集

create database jiradb character set utf8 collate utf8_bin;

  GRANT SELECt,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on <JIRADB>.* TO '<USERNAME>'@'<JIRA_SERVER_HOSTNAME>' IDENTIFIED BY '<PASSWORD>';
flush privileges;


# 给用户设定密码的两种方式
1.  UPDATE user SET password = PASSWORd('your_password') WHERe user = 'username';
    FLUSH PRIVILEGES;
2.  set password for root@localhost = password('your_password');

# 创建用户并授权用户
create user 'username'@'localhost' identified by 'your_password';
create database database_name default character set = 'utf8' default collate = 'utf8_general_ci';
grant all privileges on database_name.* to 'username'@'localhost';
flush privileges;

查看mysql数据库中的所有用户

SELECT DISTINCT CONCAt('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

查看某个用户的权限

show grants for 'nextcloud'@'%'; 

or

select * from mysql.user where user='root' \G;

查看当前用户

select user();

修改用户密码

use mysql;
UPDATE user SET password=PASSWORd('新密码') WHERe user='用户';
flush privileges;

修改用户权限及密码

grant 权限 on 库名.表名 to '用户名'@’网段‘  identified by  "该用户的密码";

grant all privileges on nextcloud.* to 'nextcloud'@'%' identified by 'du..olctx..entest.1';

删除用户

drop user 'nextcloud'@'%';

root更改密码

set password for root@localhost = password("Songhaofeng@123");



mysql> create database confluence default character set utf8 collate utf8_bin;
mysql> grant all on confluence.* to 'confluence'@'%' identified by 'confluence';
mysql> flush privileges;
如出现报错信息:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
有时候,只是为了自己测试,不想密码设置得那么复杂,譬如说,我只想设置root的密码为123456。
必须修改两个全局参数:
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
    
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)

修改MySQL初始密码

[root@localhost ~]# mysqladmin -uroot -p'/DBpfulrh8kl' password 'Song@123'
 
打赏
 本文转载自:网络 
所有权利归属于原作者,如文章来源标示错误或侵犯了您的权利请联系微信13520258486
更多>最近资讯中心
更多>最新资讯中心
0相关评论

推荐图文
推荐资讯中心
点击排行
最新信息
新手指南
采购商服务
供应商服务
交易安全
关注我们
手机网站:
新浪微博:
微信关注:

13520258486

周一至周五 9:00-18:00
(其他时间联系在线客服)

24小时在线客服