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;