mysql默認root用戶沒有密碼,輸入mysql –u root 進入mysqlmysql
一、初始化root密碼sql
進入mysql數據庫數據庫
1
|
mysql>
update
user
set
password
=
PASSWORD
(‘123456’)
where
User
=
'root'
;
|
二、容許mysql遠程訪問,能夠使用如下三種方式:服務器
a、改表。post
1
2
3
4
|
mysql -u root –p
mysql>use mysql;
mysql>
update
user
set
host =
'%'
where
user
=
'root'
;
mysql>
select
host,
user
from
user
;
|
b、受權。spa
例如,你想root使用123456從任何主機鏈接到mysql服務器。code
1
|
mysql>
GRANT
ALL
PRIVILEGES
ON
*.*
TO
'root'
@
'%'
IDENTIFIED
BY
'123456'
WITH
GRANT
OPTION
;
|
若是你想容許用戶jack從ip爲10.10.50.127的主機鏈接到mysql服務器,並使用654321做爲密碼blog
1
2
|
mysql>
GRANT
ALL
PRIVILEGES
ON
*.*
TO
'jack'
@’10.10.50.127’ IDENTIFIED
BY
'654321'
WITH
GRANT
OPTION
;
mysql>FLUSH RIVILEGES
|
c:在安裝mysql的機器上運行:ip
1
2
3
4
5
6
7
8
|
//進入MySQL服務器
d:\mysql\bin\>mysql -h localhost -u root
//賦予任何主機訪問數據的權限
mysql>
GRANT
ALL
PRIVILEGES
ON
*.*
TO
'root'
@
'%'
WITH
GRANT
OPTION
//使修改生效
mysql>FLUSH
PRIVILEGES
//退出MySQL服務器
mysql>EXIT
|
做者: 王德水
出處:http://www.cnblogs.com/cnblogsfans
版權:本文版權歸做者和博客園共有,轉載需經做者贊成。ci