以下我最終找到的答案將允許您在一個IP地址創建一個用戶,以便在另一個地址訪問MariaDB(MySQL)服務器,即使該地址是127.0.0.1
或localhost
。
在終端窗口中,鍵入:
$ sudo mysql -u root -p -h localhost
鍵入密碼:
[sudo] password for YOURUSERNAME:
鍵入MariaDB的root
密碼,或按Enter鍵(默認空密碼):
Enter password:
MariaDB顯示器歡迎橫幅出現...
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 39
Server version: 10.0.28-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
...併爲您的輸入監視器命令提示符下等待(none
意味着你沒有連接到任何數據庫尚未):
MariaDB [(none)]>
在localhost
創建一個用戶是MariaDB的將接受,並退出:
MariaDB [(none)]> CREATE USER 'root'@'%';
-> \q;
Bye
~$
這允許您至少連接,並且是允許其他用戶連接的模型。這些最小指令會留下安全漏洞,因此,在MariaDB上創建用戶後,給予用戶密碼(不要忘記root
),並授予特權和角色,這些漏洞將被關閉。
爲了增加安全性,請指定用戶計算機的IP地址,例如, 'root'@'localhost'
而不是'root'@'%'
。
Stack Overflow是編程和開發問題的網站。這個問題似乎與題目無關,因爲它不涉及編程或開發。請參閱幫助中心的[我可以詢問哪些主題](http://stackoverflow.com/help/on-topic)。也許[超級用戶](http://superuser.com/)或[Unix&Linux堆棧交換](http://unix.stackexchange.com/)會是一個更好的地方。另請參閱[我在哪裏發佈有關Dev Ops的問題?](http://meta.stackexchange.com/q/134306) – jww