本文目錄一覽:
騰訊雲伺服器怎麼開啟遠程mysql服務
查看Centos版本
[root@VM_0_7_centos ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core) 12
查看當前 Ubuntu Server版本
ubuntu@VM-15-131-ubuntu:~$ sudo lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial123456
修改user表裡面的host項
登入mysql後,更改 「mysql」 資料庫里的 「user」 表裡的 「host」 項,從」localhost」改稱」%」
mysql -uroot -proot
mysqluse mysql;
mysqlupdate user set host = ‘%’ where user = ‘root’;
mysqlselect host, user from user;
伺服器mysql怎麼配置才能遠程連接
設置mysql資料庫遠程連接:
Windows系統
1、 停止mysql的服務。
2、 進入命令窗口,然後進入MySQL的安裝目錄,比如我的安裝目錄是c:\mysql,進入c:\mysql\bin
3、 進入mysql資料庫伺服器
c:\mysql\binmysql –u root –p hkgt123
4、 選中資料庫mysql :use mysql
5、 查詢mysql資料庫中的用戶:
Select host,user,password from mysql;
6、 授權給root用戶可以從任何主機使用密碼為』hkgt123』登錄MYSQL資料庫:
GRANT ALL PRIVILEGES ON *.* TO root@』%』 IDENTIFIED BY 『hkgt123』 WITH GRANT OPTION;
7、 提交:commit;
8、 刷新許可權:flush privileges;
mysql如何遠程連接伺服器?
1、 停止mysql的服務。
2、 進入命令窗口,然後進入MySQL的安裝目錄,比如安裝目錄是c:\mysql,進入c:\mysql\bin。
3、 進入mysql資料庫伺服器。
c:\mysql\binmysql –u root –p hkgt123。
4、 選中資料庫mysql :use mysql。
5、 查詢mysql資料庫中的用戶:Select host,user,password from mysql。
6、 授權給root用戶可以從任何主機使用密碼為』hkgt123』登錄MYSQL資料庫:
GRANT ALL PRIVILEGES ON *.* TO root@』%』 IDENTIFIED BY 『hkgt123』 WITH GRANT OPTION。
7、 提交:commit。
8、 刷新許可權:flush privileges。
如何連接遠程Mysql資料庫
一、配置mysql允許遠程鏈接
默認情況下,mysql帳號不允許從遠程登陸,只能在localhost登錄。這裡提供了二種方法設置mysql可以通過遠程主機進行連接。
1、改表法
在localhost登入mysql後,更改
“mysql”
資料庫里的
“user”
表裡的
“host”
項,將”localhost”改稱”%”
例如:
#mysql
-u
root
-p
enter
password:
……
mysql
mysqlupdate
user
set
host
=
‘%’
where
user
=
‘root’;
mysqlselect
host,
user
from
user;
2、授權法
例如:
你想myuser使用mypassword(密碼)從任何主機連接到mysql伺服器的話。
mysqlgrant
all
privileges
on
*.*
to
‘myuser’@’%’identified
by
‘mypassword’
with
grant
option;
如果你想允許用戶myuser從ip為192.168.1.6的主機連接到mysql伺服器,並使用mypassword作為密碼
mysqlgrant
all
privileges
on
*.*
to
‘myuser’@’192.168.1.3’identified
by
‘mypassword’
with
grant
option;
mysqlflush
privileges
使修改生效,就可以了。
二、連接遠程資料庫:
1、顯示密碼
如:mysql
連接遠程資料庫(192.168.5.116),埠「3306」,用戶名為「root」,密碼「123456」
c:/mysql
-h
192.168.5.116
-p
3306
-u
root
-p123456
2、隱藏密碼
如:mysql
連接本地資料庫,用戶名為「root」,
c:/mysql
-h
localhost
-u
root
-p
enter
password:
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/181744.html