一,安装mysql
apt-get install mysql-server mysql-client
二,验证是否安装成功
mysql -uroot -p
如果安装成功,将进入mysql界面
三、设置对外开放3306
1,修改配置文件:
vim /etc/mysql/my.cnf
找到
bind-address = 127.0.0.1
改为:
bind-address = 0.0.0.0
#允许任意ip地址访问
也可以指定IP地址。
重启MySQL:
sudo /etc/init.d/mysqld restart
2,修改数据库配置:
授权root用户进行远程连接
grant all privileges on *.* to root@"%" identified by "password" with grant option;
flush privileges;
第二行命令使设置生效。
四,mysql的重启
root@dsafds:~# service mysql restart
mysql stop/waiting
mysql start/running, process 11853