安装:mysql
sudo apt update sudo apt install mysql-server
安装过程会须要输入密码。sql
登陆:less
mysql -u root -p
容许远程登陆:ide
直接启动,用别台机器远程登陆会有2003的错误,容许远程登陆作了以下尝试:3d
1)登陆以后,尝试修改root的host为%rest
show databases; use mysql; select user, host from user;
update user set host = "%" where user = "root";
因为存在多个root user,致使更新并不成功。(若是仅有一个root user,这种方式能够成功)code
2)更新权限:server
grant all privileges on *.* to "root"@"%" identified by "root" with grant option; flush privileges;
可是远程访问仍是报了2003的错误。blog
3)修改配置,重启mysql:ip
找到mysql的配置文件/etc/mysql/my.cnf, 将"bind-address = 127.0.0.1"注释掉
# # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. #bind-address = 127.0.0.1
重启mysql服务
sudo service mysql restart
通过这么多尝试以后,终于能够远程登陆了!