MySql 建立使用者與資料庫的實際操作步驟

來源:互聯網
上載者:User

標籤:資料表   root許可權   重新整理   com   href   一個   建立使用者   localhost   from   

以下的文章主要講述的是MySql 建立使用者的建立、建立資料庫的實際操作步驟以及使用者如何進行授權和刪除使用者的實際操作方案、還有對修改密碼的實際操作,以下就是本文的主要內容的建立。

1.MySql 建立使用者。

登入MYSQL

@>mysql -u root -p

@>密碼

建立使用者

  1. mysql> mysql> insert into mysql.user(Host,User,Password,ssl_cipher,x509_issuer,x509_sub  
  2. ject) values("localhost","pppadmin",password("passwd"),‘‘,‘‘,‘‘); 

這樣就建立了一個名為:phplamp 密碼為:1234 的使用者。

然後登入一下。

mysql>exit;

@>mysql -u phplamp -p

@>輸入密碼

mysql>登入成功

2.為使用者授權。

登入MYSQL(有ROOT許可權)。我裡我以ROOT身份登入.

@>mysql -u root -p

@>密碼

首先為MySql 建立使用者建立一個資料庫(phplampDB)

  1. mysql>create database phplampDB; 

授權phplamp使用者擁有phplamp資料庫的所有許可權。

  1. >grant all privileges on phplampDB.* to [email protected] identified by ‘1234‘; 

重新整理系統許可權表

  1. mysql>flush privileges; 

mysql>其它操作

/*

如果想指定部分許可權給一使用者,可以這樣來寫:

  1. mysql>grant select,update on phplampDB.* to [email protected] identified by ‘1234‘; 

重新整理系統許可權表。

  1. mysql>flush privileges;  
  2. */ 

3.刪除使用者。

@>mysql -u root -p

@>密碼

  1. mysql>DELETE FROM user WHERE User="phplamp" and Host="localhost";  
  2. mysql>flush privileges; 

刪除使用者的資料庫

  1. mysql>drop database phplampDB; 

4.修改指定使用者密碼。

@>mysql -u root -p

@>密碼

  1. mysql>update mysql.user set passwordpassword=password(‘新密碼‘) where User="phplamp" and Host="localhost";  
  2. mysql>flush privileges; 

5.列出所有資料庫

mysql>show database;

6.切換資料庫

mysql>use ‘資料庫名‘;

7.列出所有表

mysql>show tables;

8.顯示資料表結構

mysql>describe 表名;

9.刪除資料庫和資料表

mysql>drop database 資料庫名;

mysql>drop table 資料表名;

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.