數(shù)據(jù)庫必須具有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;
# 給用戶設(shè)定密碼的兩種方式
1. UPDATE user SET password = PASSWORD('your_password') WHERE user = 'username';
FLUSH PRIVILEGES;
2. set password for root@localhost = password('your_password');
# 創(chuàng)建用戶并授權(quán)用戶
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數(shù)據(jù)庫中的所有用戶
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
查看某個用戶的權(quán)限
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;
修改用戶權(quán)限及密碼
grant 權(quán)限 on 庫名.表名 to '用戶名'@’網(wǎng)段‘ 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;
如出現(xiàn)報錯信息:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
有時候,只是為了自己測試,不想密碼設(shè)置得那么復雜,譬如說,我只想設(shè)置root的密碼為123456。
必須修改兩個全局參數(shù):
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'