1 檢查確認安裝了.
怎么檢查是否安裝了MySQL?
brew search mysql
怎么卸載了呢?
brew list mysql 查看安裝的路徑. 重啟心動下就好了
brew uninstall mysql 就可以
2 mac進行安裝
brew install mysql 安裝中
3 mac進行啟動, 并加入開機啟動.
1 怎么啟動呢???
sudo /usr/local/mysql/support-files/mysql.server start restart stop?
brew services start mysql
2 怎么加入開機啟動呢??
https://www.jb51.net/article/57818.htm
3 brew太慢了, 更新一下brew origin?
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
brew update
4 增刪該查一下
1 登錄數據庫
mysql -uroot -hlocalhost -p
2 增刪改查
use test;
insert into test(id, name, price, num, date) values(100, 'good', 100, '2020-01-01')
select * from test;
delete from test where id = 5;
update test set name = 'update_name' where id = 5;
3 用軟件連接數據? mysqlworkbench
5 配置常用連接總數
mysql --verbose --help | grep my.cnf? 查看配置文件再哪里??
show VARIABLES like 'max_con%'; 客戶端查看變量
vim /usr/local/etc/my.cnf? 配置文件
1 連接總數.? ?max_connections
show global variables;?
如何設置呢?? , 首先查看最大連接數
show global status like 'Max_used_connections';
假如是 max_used_connections=850 ,?max_connections = 1000? 比較合理占比85%?
max_used_connections / max_connections * 100% (理想值≈ 85%)
2 連接超時時間??
connect_timeout = 10;
3 socker登錄
[mysqld]
socket = /usr/local/Cellar/mysql/8.0.18_1/lib/mysql.lock 配置一個文件 , 就可以用socket登錄了
mysql -uroot --socket=/usr/local/Cellar/mysql/8.0.18_1/lib/mysql.lock -p
4 其他常用配置
https://www.cnblogs.com/zhshto/p/6653424.html
5 配置錯誤日志?
安裝的mysql 8.0最新版, 各種坑, 扛不住.?
然后把它卸載了
brew uninstall mysql?
brew install mysql@5.6
修改初始密碼
(1)執(zhí)行 cd /usr/local/mysql/bin
(2)執(zhí)行 vim ~/.bash_profile
? ? ? 在該文件中添加mysql/bin的目錄
? ? ? export PATH=$PATH:/usr/local/mysql/bin
添加完成后,按esc浑塞,然后輸入wq保存赴魁。
最后執(zhí)行 source ~/.bash_profile
復制代碼
(1) 如果你終端還在第三步, 不執(zhí)行第一步 cd /usr/local/mysql/bin/
(2) 登錄管理員權限 sudo su
(3) 回車后輸入密碼然后輸入以下命令來禁止mysql驗證功能 ./mysqld_safe --skip-grant-tables &
注意: 回車后mysql會自動重啟(偏好設置中mysql的狀態(tài)會變成running)
(4) 輸入命令 ./mysql
(5) 回車后室埋,輸入命令 FLUSH PRIVILEGES;
(6) 回車后谬莹,輸入命令 SET PASSWORD FOR 'root'@'localhost' = PASSWORD('你的新密碼'); // 比如 1234
(7) 重新打開新終端 執(zhí)行 mysql -uroot -p 回車 輸入密碼回車
form?https://www.cnblogs.com/fooller/p/11121602.html