Note that this is Not very secure, and should only be used for a local development box where you don’t feel like setting up individual permissions, but still need to connect from other machines.
請注意,這不是很安全,僅應用于您不想設置個人權限,但仍需要從其他計算機連接的本地開發箱。
To configure this feature, you’ll need to update the mysql user table to allow access from any remote host, using the % wildcard.
要配置此功能,您需要使用%通配符更新mysql用戶表,以允許從任何遠程主機進行訪問。
Open the command-line mysql client on the server using the root account.
使用根帳戶打開服務器上的命令行mysql客戶端。
mysql -uroot
mysql -uroot
Then you will want to run the following two commands, to see what the root user host is set to already:
然后,您將需要運行以下兩個命令,以查看root用戶主機已設置為什么:
use mysql;select host, user from user;
使用mysql;從用戶中選擇主機,用戶;
Here’s an example of the output on my database, which is pretty much the default settings. Note that ubuntuserv is the hostname of my server.
這是數據庫輸出的示例,幾乎是默認設置。 請注意,ubuntuserv是我的服務器的主機名。
mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changed
mysql>使用mysql;讀取表信息以完成表和列名可以通過更改-ADatabase來關閉此功能以更快地啟動
mysql> select host,user from user;+—————+——————+| host | user |+—————+——————+|?ubuntuserv | root | | localhost | debian-sys-maint | | localhost | root | +—————+——————+3 rows in set (0.00 sec)
mysql>從用戶中選擇主機,用戶; + —————— + —————— + | 主機| 用戶| + —————— + —————— + | ubuntuserv | 根| | 本地主機| debian-sys-maint | | 本地主機| 根| + —————— + —————— ++ 3行(0.00秒)
Now I’ll update the ubuntuserv host to use the wildcard, and then issue the command to reload the privilege tables. If you are running this command, substitute the hostname of your box for ubuntuserv.
現在,我將更新ubuntuserv主機以使用通配符,然后發出命令以重新加載特權表。 如果您正在運行此命令,請用方框的主機名代替ubuntuserv。
update user set host=’%’ where user=’root’ and host=’ubuntuserv’;flush privileges;
更新用戶集host ='%',其中user ='root'和host ='ubuntuserv';刷新權限;
That’s all there is to it. Now I was able to connect to that server from any other machine on my network, using the root account.
這里的所有都是它的。 現在,我可以使用根帳戶從網絡上的任何其他計算機連接到該服務器。
Again, note this isn’t very secure, and you should at least make sure that you’ve set a root password.
再次提醒您,此操作不是很安全,并且至少應確保已設置root密碼。
翻譯自: https://www.howtogeek.com/howto/programming/mysql-give-root-user-logon-permission-from-any-host/