MySQL for mac使用記錄

來源:互聯網
上載者:User

標籤:

一、登入

開啟終端,輸入/usr/local/mysql/bin/mysql -u root -p

初次進入mysql,密碼為空白。當出現mysql>提示符時,表示你已經進入mysql中。鍵入exit退出mysql。

 

二、更改Mysqlroot使用者密碼

更改mysql root 使用者密碼,在終端輸入/usr/local/mysql/bin/mysqladmin -u root password新密碼

設定新的密碼,再次輸入/usr/local/mysql/bin/mysql -u root -p登入:

 

三、建立使用者

以root身份登入mysql:

建立一個使用者,鍵入insert into mysql.user(Host,User,Password) values("localhost","新使用者",password("密碼"));

重新整理系統許可權表,鍵入 flush privileges;

這樣就建立了一個使用者名稱為Lands,密碼為Lands的使用者。嘗試用新使用者密碼登入:

 

四、刪除使用者

登入root 賬戶。

刪除使用者,鍵入 DELTE FROM mysql.user WHERE User="使用者名稱";

重新整理許可權表,鍵入 flush privileges;

 

五、修改指定使用者密碼

登入root 賬戶。

修改指定使用者密碼,鍵入update mysql.user set password=password("新密碼") where User="使用者名稱" and Host="localhost";

重新整理許可權表,鍵入 flush privileges;

 

六、為使用者建立資料庫

登入root 賬戶。 先建立一個資料庫:鍵入 create database 資料庫名;

然後為使用者添加操作資料庫的許可權,鍵入 grant all privileges on 資料庫名.* to 使用者名稱@localhost identified by ‘使用者名稱‘;

重新整理許可權表,鍵入 flush privileges;

如果只指定部分許可權給使用者,鍵入grant select,update on 資料庫名.* to 使用者名稱@localhost identified by ‘使用者名稱‘; 重新整理許可權表,

鍵入 flush privileges;

 

七、操作資料庫

登入root 賬戶。

1、建立一個新的資料庫,鍵入 create database 資料庫名;

2、開啟一個資料庫,鍵入 use 資料庫名;

3、顯示資料庫中所有的資料表,鍵入 show tables;

4、建立一個資料庫表,鍵入create table資料表名(欄位1 欄位類型, 欄位2 欄位類型);

5、顯示表的結構,鍵入 describe 資料表名;

 

6、在表中插入資料,鍵入 insert into 資料表名 value("欄位值1", "欄位值2");

7、更新表中資料,鍵入 update 資料表名 set 欄位1=欄位值1 where 篩選條件;

8、刪除表中資料,鍵入 delete from 資料表名 where 查詢條件;

9、清空表中資料,鍵入 delete from 資料表名;

10、刪除資料表,鍵入 drop table 資料表名;

MySQL for mac使用記錄

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.