mysql

windows 10安裝

版本:8.0

https://www.itread01.com/article/1538100635.html

如果加裝workbench需要額外安裝vs 2019

https://support.microsoft.com/zh-tw/help/2977003/the-latest-supported-visual-c-downloads

新版密碼安全性更好,具體使用差異尚未研究,求開發方便先選舊版的

參考文章: https://blog.csdn.net/chenlu5201314/article/details/80017115

start/stop

先至windows電腦管理中尋找mysql的服務名稱 (可能叫做mysql or mysql80),我的叫mysql80

如果找不到服務名稱:

以管理員身分開啟cmd

cd 至mysql安裝目錄,例如:C:\Program Files\MySQL\MySQL Server 8.0\bin>

執行指令

mysqld --install

完成後再以管理員身分開啟cmd,任一目錄即可輸入指令

net stop mysql80
net start mysql80

最後可在workbench查詢server status

參考文章: https://www.twblogs.net/a/5cc35ca7bd9eee3aed78cf14 https://blog.csdn.net/weixin_40918145/article/details/82629514

帳號管理與外部連線

root會在安裝時就設定密碼,其他新帳號可安裝完成後再用workbench新增,記得開權限

http://sharedderrick.blogspot.com/2017/02/mysql-workbench.html

除了workbench也可使用cmd設定

先cd到安裝路徑,如:C:\Program Files\MySQL\MySQL Server 8.0\bin

  1. 打開cmd,以root登入:

mysql -u root -p
  1. 選擇 mysql 資料庫

use mysql;
  1. 查看目前使用者設定資訊

select host, user, authentication_string, plugin from user;

執行完上面的命令後會顯示一個表格 ,其中host預設應該都是顯示 localhost,只支援本地訪問,不允許遠端訪問。

  1. 授予權限,這邊是賦予root外部連線權限

GRANT ALL ON *.* TO 'root'@'%';

GRANT ALL ON 表示所有許可權,% 表示通配所有 host,可以訪問遠端。

  1. 重新整理

flush privileges;

可再次執行步驟3指令,若host已改成 % ,則可嘗試用ip進行連線

若要新增使用者:

create user 'xxx'@'%' identified by 'xxx';

再授權

grant all privileges on *.* to 'xxx'@'%' with grant option;

刪除使用者

delete from mysql.user where user='username' and host='localhost';

參考資料:

https://www.itread01.com/content/1549041846.html

https://blog.xuite.net/relay/blog/10809799-%E5%88%AA%E9%99%A4mysql%E7%9A%84%E4%BD%BF%E7%94%A8%E8%80%85

資料型態

http://n.sfs.tw/content/index/10266

peewee 當中的資料型態:http://docs.peewee-orm.com/en/latest/peewee/models.html

query

http://www.codedata.com.tw/database/mysql-tutorial-5-join-union

http://www.codedata.com.tw/database/mysql-tutorial-9-subquery/

刪除方式比較

https://byron0920.pixnet.net/blog/post/85759990

產生ERD (WORKBENCH)

https://www.zhihu.com/question/20680795

Issue

ERROR 1410 (42000): You are not allowed to create a user with GRANT

分配帳號時遇到的錯誤

5.7和8的授權指令不同,5.7可參考以下指令,在8.0則會出錯

grant all privileges on *.* to 'root'@'%' identified by '123123';

https://blog.csdn.net/qq_34680444/article/details/86238516

pymysql.err.OperationalError: (1040, 'Too many connections')

進行系統壓力測試所遇到的錯誤,開啟my.ini更改預設數量

https://www.itread01.com/p/1135789.html

https://www.jianshu.com/p/f682d5e7bc96

Last updated