mysql

  1. 創(chuàng)建用戶
create user 'username'@'localhost' identified by 'password';//其中l(wèi)ocalhost是指定可以從哪個(gè)主機(jī)連接,%代表所有主機(jī)都能連接
  1. 給用戶分配權(quán)限
grant all privileges on www_xxx_cn.* to 'username'@'localhost';//給與所有權(quán)限到數(shù)據(jù)庫www_xxx_cn中所有的表;其中username和localhost要和mysql庫中user表中(剛剛創(chuàng)建的)一致,否則無法連接
  1. 修改權(quán)限后可能需要刷新下
flush privileges;
  1. 有時(shí)候提示密碼不夠安全(not safetiy)ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
show variables like 'validate_password%';//查看全局的變量,見下圖
//修改變量
set global validate_password.special_char_count = 0;//取消密碼中特殊字符的數(shù)量為0
查看全局的變量
  1. 導(dǎo)入數(shù)據(jù)
mysql -u username -p www_xxx_cn < file.sql;//指定導(dǎo)入文件和數(shù)據(jù)庫,下一步輸入密碼,若提示密碼不安全,看第四條
  1. 導(dǎo)出數(shù)據(jù)
mysqldump ;//查吧lol
  1. 數(shù)據(jù)庫在本地,網(wǎng)站在docker中,一定記得查詢出docker的ipdocker inspect 容器查看(最好綁定IP,不然每次可能會(huì)變),并且在上面的所有l(wèi)ocalhost指定為docker的ip,否則連接不到。注意:在創(chuàng)建的時(shí)候如果指定了docker的ip那么就不能用創(chuàng)建的用戶來導(dǎo)入了,因?yàn)檫@時(shí)我們導(dǎo)入是在localhost導(dǎo)入,所以正確的順序是: 創(chuàng)建localhost用戶 -> 授權(quán)l(xiāng)ocalhost -> 導(dǎo)入 -> 修改localhost為docker ip -> 修改授權(quán)(grant那一段)-> flush privileges,

https://blog.csdn.net/wengzilai/article/details/78871414

  1. 復(fù)制數(shù)據(jù)
create TEMPORARY table tmp SELECT * from user where user="root";
update tmp set host = "%" where user="root";
insert user select * from tmp where user="root";
image.png
最后編輯于
?著作權(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ù)。

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