回顧:Linux環境 Mysql建立使用者和資料庫並授權

來源:互聯網
上載者:User

標籤:linux環境   use   ice   res   建立   service   資料   safe   回顧   

 回顧:Linux環境 Mysql建立使用者和資料庫並授權

一、建立使用者

//登入Mysql

@>mysql -u root -p@>密碼


//建立使用者

 

mysql> insert into mysql.user(Host,User,Password)values(‘localhost‘,‘xdev‘,password(‘xdev123‘));//重新整理系統許可權表mysql>flush privileges;//這樣就建立了一個名為:xdev密碼為:xdev123 的使用者。

 

二、登入測試

mysql>exit;@>mysql -u cplusplus -p@>輸入密碼mysql>登入成功


三、使用者授權

//登入MYSQL@>mysql -u root -p@>密碼//首先為使用者建立一個資料庫(tz_ebank)mysql>create database tz_ebank;//給來自10.163.225.87的使用者joe分配可對資料庫vtdc的employee表進行select,insert,update,delete,create,drop等操作的許可權,並設定口令為123。mysql>grant select,insert,update,delete,create,drop on vtdc.employee to [email protected]‘%‘ identified by ‘123‘;//給來自10.163.225.87的使用者joe分配可對資料庫vtdc所有表進行所有操作的許可權,並設定口令為123。mysql>grant all privileges on vtdc.* to joe@10.163.225.87 identified by ‘123‘;//給來自10.163.225.87的使用者joe分配可對所有資料庫的所有表進行所有操作的許可權,並設定口令為123。mysql>grant all privileges on *.* to joe@10.163.225.87 identified by ‘123‘;//給本機使用者joe分配可對所有資料庫的所有表進行所有操作的許可權,並設定口令為123。mysql>grant all privileges on *.* to joe@localhost identified by ‘123′;

 

四,linux下開啟、關閉、重啟mysql服務命令


一、 啟動
1、使用 service 啟動:service mysql start
2、使用 mysqld 指令碼啟動:/etc/inint.d/mysql start
3、使用 safe_mysqld 啟動:safe_mysql&

二、停止
1、使用 service 啟動:service mysql stop
2、使用 mysqld 指令碼啟動:/etc/inint.d/mysql stop
3、mysqladmin shutdown

三、重啟
1、使用 service 啟動:service mysql restart
2、使用 mysqld 指令碼啟動:/etc/inint.d/mysql restart

 

四、查看mysql狀態

 

>>mysql

 

回顧:Linux環境 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.