Mysql帳號管理

來源:互聯網
上載者:User

標籤:

一 使用者添加

  1. 通過insert 方式添加使用者

insert into mysql.user(Host,User,Password) values("localhost","sa",password("admin123"))

出現異常:

   DBCException: SQL Error [1364] [HY000]: Field ‘ssl_cipher‘ doesn‘t have a default value

  java.sql.SQLException: SQLException: Field ‘ssl_cipher‘ doesn‘t have a default value

異常原因:禁止通過insert 方式修改使用者user

 解決方式:在my.cnf中有這樣一條語句:sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES。

將改為:sql_mode=NO_ENGINE_SUBSTITUTION。

     重啟伺服器。

  1. 通過命令create

CREATE USER ‘sa‘@‘127.0.0.1‘ IDENTIFIED BY "admin123";

192.168.189.%:ip可以通過使用萬用字元來限制使用者的ip

二 . 使用者刪除

DELETE FROM user WHERE User=”sa” and Host=”localhost”;
flush privileges;

三.  修改密碼

update mysql.user set password=password(‘新密碼’) where
User=”sa” and Host=”localhost”;
flush privileges;

四. 使用者授權

create database cplusplusDB;
//授權cplusplus使用者擁有cplusplusDB資料庫的所有許可權。
grant all privileges on cplusplusDB.* to [email protected] identified
by ‘admin123‘;
//重新整理系統許可權表
mysql>flush privileges;

五. 部分授權

grant select,update on cplusplusDB.* to [email protected]
identified by ‘admin123‘;
//重新整理系統許可權表。
flush privileges;

Mysql帳號管理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.