linux上的mysql配置过程

  自己阿里云上的服务器,记录下mysql的配置过程防止后面忘记

  1. 首先用apt-get工具安装mysql

sudo apt-get install mysql-server 
sudo apt-get install mysql-client

  2. 观察主配置文件

cd /etc/mysql
vi ./debian.cnf

  其中user = debian-sys-maint,而password就是这个用户的密码,用这个帐号和密码登录mysql

mysql -udebian-sys-maint -p

  然后修改root的帐号和密码

update mysql.user set authentication_string=PASSWORD('newPwd'), plugin='mysql_native_password' where user='root';

  修改mysqld.cnf配置文件,将其中的bind-address注释掉,防止外部访问失败

cd /etc/mysql/mysql.conf.d
vi mysqld.cnf
#bind-address = 127.0.0.1

  重启mysql服务

service mysql restart

  登录阿里云主页,将访问策略中添加3306(mysql的默认端口)

  至此完毕,可以在外部使用navicat等软件连接mysql

猜你喜欢

转载自www.cnblogs.com/colourstar/p/10578876.html