在mysql的user表中存儲了MySQL的用戶信息
主要字段:mysql
desc user; # 查看用戶信息
# root帳戶登陸 mysql -uroot -p # 經常使用權限列表:create、alter、drop、insert、update、delete、select 若是分配全部權限,能夠使用all privileges # 訪問主機一般使用:百分號%,表示此帳戶能夠使用任何ip的主機登陸訪問此數據庫 # 訪問主機能夠設置成 localhost或具體的ip,表示只容許本機或特定主機訪問 grant 權限名稱 on 數據庫 to '用戶名'@'訪問主機' identified by '密碼'; # 查看用戶有哪些權限 show grants for laowang@localhost; # 退出root登陸 quit
grant 權限名稱 on 數據庫 to 帳戶@主機 with grant option;
update user set authentication_string=password('新密碼') where user='用戶名'; flush privileges; # 刷新權限
# 方法一 drop user '用戶名'@'主機'; # 方法二 delete from user where user='用戶名'; flush privileges
vim /etc/mysql/mysql.conf.d/mysqld.cnf bind-address = 0.0.0.0 service mysql restart # 重啓