ubuntu 安装mysql
作者:互联网
1. 安装mysql服务器、客户端及客户端开发工具
sudo apt install mysql-server mysql-client libmysqlclient-dev
2.设置远程访问mysql
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
注释掉bind-address = 127.0.0.1这一行,保存退出编辑
mysql -u root -p
进入mysql服务,输入如下命令允许任何机器访问mysql服务器:
法一:修改权限法:
mysql> grant all privileges on *.* to 'root'@'%' identified by 'mypassword' with grant option; mysql> flush privileges;
法二:修改表法:
mysql> select host,user from user;
结果如下:
mysql> select host,user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| localhost | debian-sys-maint |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+------------------+
4 rows in set (0.01 sec)
将user为root的用户的host改为%:
mysql> update user set host='%' where user='root';
再次查询结果如下:
mysql> select host,user from user; +-----------+------------------+ | host | user | +-----------+------------------+ | % | root | | localhost | debian-sys-maint | | localhost | mysql.session | | localhost | mysql.sys | +-----------+------------------+ 4 rows in set (0.00 sec)
使修改生效:
mysql> flush privileges;
3.使用mysql客户端gui工具(navicat)连接mysql服务
标签:+-----------+------------------+,root,mysql,host,user,ubuntu,安装,localhost 来源: https://blog.51cto.com/u_4135183/2821387