mysql默認root用戶沒有密碼,輸入mysql –u root 進入mysqlmysql
一、初始化root密碼sql
進入mysql數據庫數據庫
mysql>update user set password=PASSWORD('123456') where User='root';
二、容許mysql遠程訪問,有如下幾中方式vim
若是不容許遠程訪問,會報以下的錯誤:
this
ERROR 1130 (HY000): Host ‘1.2.3.4’ is not allowed to connect to this MySQL serverspa
(1)、Change mysql configrest
vim /etc/mysql/my.cnf
Comment out following lines.code
#bind-address = 127.0.0.1 #skip-networking
If you do not find skip-networking line, add it and comment out it.server
Restart mysql server.blog
/etc/init.d/mysql restart
(2)、Change GRANT privilege
Run a command like below to access from all machines. (Replace USERNAME
and PASSWORD
by your credentials.)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
Run a command like below to give access from specific IP. (Replace USERNAME
and PASSWORD
by your credentials.)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
Finally, you may also need to run:
mysql> FLUSH PRIVILEGES;