mysql安裝使用

apt安裝
sudo apt install mysql-server
常用配置

參考:mysql配置文件

[mysqld]
basedir             = /usr // 安裝目錄
socket              = /usr/local/mysql/data/mysql.sock // mysql客戶端程序和服務(wù)器之間的本地通訊時(shí)使用的套接字文件
pid-file            = /usr/local/mysql/data/mysql.pid // pid文件所在目錄
datadir             = /var/lib/mysql // 數(shù)據(jù)文件存放的目錄
bind_address        = 127.0.0.1 // 綁定的IP地址
port                = 3306 // 監(jiān)聽(tīng)端口號(hào)
skip-grant-tables   = 1 // 跳過(guò)權(quán)限認(rèn)證
常用管理命令
  • mysql服務(wù)啟停
#啟動(dòng)
sudo service mysql start
#停止
sudo service mysql stop
  • 檢查服務(wù)狀態(tài)
systemctl status mysql.service
sudo service mysql status
  • 新增用戶
create user "username"@"host" identified by "password";
  //host="localhost"為本地登錄用戶,host="ip"為ip地址登錄,host="%"為外網(wǎng)ip登錄
create user 'test'@'localhost' identified by 'test';
create user 'test'@'192.168.1.2' identified by 'test';
create user 'test'@'%' identified by 'test';
  • 修改密碼
 SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
  • 刪除用戶
drop user 'username'@'host';
  • 授權(quán)
grant privileges on databasename.tablename to 'username'@'host' IDENTIFIED BY 'PASSWORD';
 /*授予用戶通過(guò)外網(wǎng)IP對(duì)于該數(shù)據(jù)庫(kù)的全部權(quán)限*/
grant all privileges on `test`.* to 'test'@'%' ;
/*授予用戶在本地服務(wù)器對(duì)該數(shù)據(jù)庫(kù)的全部權(quán)限*/
grant all privileges on `test`.* to 'test'@'localhost';   
grant select on test.* to 'user'@'localhost';  /*給予查詢權(quán)限*/
grant insert on test.* to 'user'@'localhost'; /*添加插入權(quán)限*/
grant delete on test.* to 'user'@'localhost'; /*添加刪除權(quán)限*/
grant update on test.* to 'user'@'localhost'; /*添加權(quán)限*/
flush privileges; /*刷新權(quán)限*/
  • 刪除權(quán)限
revoke privileges on databasename.tablename from 'username'@'host';
revoke delete on test.* from 'user'@'localhost';
  • 查詢權(quán)限
show grants;
常見(jiàn)問(wèn)題

mysql 8.0 版本以上如何修改root密碼

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 學(xué)習(xí)目的 掌握如何安裝Mysql 掌握Mysql的基礎(chǔ)配置 了解如何完全卸載Mysql 一.Mysql下載與安裝 ...
    從前的小余兒閱讀 460評(píng)論 0 0
  • 一、CentOS 7下啟動(dòng)、關(guān)閉、重啟、查看MySQL服務(wù) 1.啟動(dòng)命令 2.關(guān)閉命令 3.重啟命令 4.查看服務(wù)...
    EllisonPei閱讀 316評(píng)論 0 0
  • 一.介紹 MySQL是一個(gè)關(guān)系型數(shù)據(jù)庫(kù)管理系統(tǒng),由瑞典MySQL AB 公司開(kāi)發(fā),目前屬于 Oracle 旗下產(chǎn)品...
    走著別浪閱讀 427評(píng)論 0 2
  • 對(duì)于網(wǎng)站或其他應(yīng)用來(lái)說(shuō),數(shù)據(jù)是最重要,而數(shù)據(jù)既可以存在文本文件中,也可以存在內(nèi)存中,為了方便管理,一般都會(huì)數(shù)據(jù)庫(kù)來(lái)...
    MsgSS閱讀 851評(píng)論 1 1
  • 參考鏈接:https://www.cnblogs.com/dion-90/articles/8349488.htm...
    minlover閱讀 336評(píng)論 0 0

友情鏈接更多精彩內(nèi)容