ubuntu mysql 安装和外网访问配置

1. sudo apt-get install mysql-server

  

2. 公网访问配置

mysql -u root -p

use mysql;

所有主机能够访问

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'  IDENTIFIED BY 'you_password'  WITH GRANT OPTION;

flush privileges;

有限制主机访问的

GRANT ALL PRIVILEGES ON *.* TO 'root'@'you_ip'   IDENTIFIED BY 'you_password'  WITH GRANT OPTION; 

flush privileges;


3.出现"ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)"

查看 /etc/mysql/my.cnf

msyql默认的bind-address是127.0.0.1

将其改成0.0.0.0,然后 /etc/init.d/mysql restart 重启服务器


你可能感兴趣的:(ubuntu)