Editing
排除 MySQL 技術疑難問題
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== [Warning] Using a password on the command line interface can be insecure === 問題描述: 使用 bash 命令匯出或匯入 MySQL 資料庫時,可能會遇到以下警告:[警告] 在命令行介面上使用密碼可能不安全。 <pre> mysql: [Warning] Using a password on the command line interface can be insecure. or mysqldump: [Warning] Using a password on the command line interface can be insecure. </pre> 這通常發生在使用如下命令時: <pre> mysqldump -u USERNAME -p -h 127.0.0.1 --default-character-set=utf8 DATABASE > DATABASE.sql </pre> 解決方案:要解決此警告並提高安全性,請按照以下步驟操作: # 使用 [https://dev.mysql.com/doc/refman/8.4/en/mysql-config-editor.html mysql_config_editor] 設定登入路徑 (login path):{{kbd | key=<nowiki>mysql_config_editor set --login-path=local --host=localhost --user=root --password</nowiki>}} # 匯出或匯入 MySQL 資料庫時使用登入路徑 (1) 匯出時:{{kbd | key=<nowiki>mysqldump --login-path=local --default-character-set=utf8 資料庫名稱 > 資料庫名稱.sql</nowiki>}} (2) 匯入時:{{kbd | key=<nowiki>pv 資料庫名稱.sql.gz | gunzip | mysql --login-path=local --default_character_set utf8 --force 資料庫名稱</nowiki>}} # 查看所有已設定的登入路徑 {{kbd | key=<nowiki>mysql_config_editor print --all</nowiki>}} 透過使用登入路徑,可以避免在命令行中暴露密碼,解決安全警告。
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information