Ubuntu server安裝MySQL並配置遠程連接


1.  在Ubuntu server 安裝MySQL(過程中注意記住設置的密碼)

Sudo apt-get install mysql

Sudo apt-get install mysql-server

Sudo apt-get install mysql-client

備注:此處遇到MySQL無法安裝的問題,提示dpkg:error processing package open-vm-tools(--configure)錯誤,解決方法是清除open-vm-tools之后重新安裝,sudo apt-get purge open-vm-tools, sudo apt-get install open-vm-tools.

2. 配置MySQL連接賬戶

         進入MySQL環境(mysql –u root –p)

         User mysql

         添加賬戶

(insert into mysql.user(Host,User,Password) values (“localhost”,”test”,password(“pass”));)

localhost指的本地,如果需要遠程連接,host可設置為”%”

備注:在使用用戶進入MySQL環境時,遇到提示access denied問題,解決方法是更新mysql.user表中的authentication_string字段,update mysql.user set authentication_string=password(‘pass’) where user=’test’ and Host=’localhost’

3. 對用戶進行授權

         命令:grant all privileges on databasename.tablename to ‘test’ @’localhost’ identified by ‘pass’ with grant option;

         databasename - 數據庫名,tablename-表名,如果要授予該用戶對所有數據庫和表的相應操作權限則可用*表示,如*.*

         @后指代主機,需要全部則添加@’%’

4. 遠程使用sqlyog連接,端口默認3306

 

 

備注:此處遇到連接提示1045的錯誤,解決方式是要對mysql.user表中對應的用戶,host設置為連接用ip,並設置authentication_string 和 對此用戶進行授權


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM