1、安装mysql
- 打开终端输入下面命令
sudo apt install mysql-server
输入root密码1.png
输入root密码2.png - 执行
sudo apt install mysql-client
- 执行
sudo apt install libmysqlclient-dev
2、查询是否安装成功
sudo netstat -tap | grep mysql
mysql安装成功.png
3、开启远程访问mysql
- 编辑mysql配置文件,注释掉"bind-address = 127.0.0.1"
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
注释bind-address.png - 进入mysql root账户
mysql -u root -p
- 在mysql环境中输入grant all on . to username@’%’ identified by ‘password’;或者grant all on . to username@’%’ identified by ‘password’ with grand option;
注:username 和 password即为提供别人远程访问的帐号和密码
grant all on *.* to root@'%' identified by 'root';
mysql设置远程帐号和密码.png - 刷新
flush privileges;
然后重启mysql,通过/etc/init.d/mysql restart
命令
刷新.png
重启mysql.png