linux系统上的mysql开启远程链接 |
您所在的位置:网站首页 › 怎么允许远程访问 › linux系统上的mysql开启远程链接 |
文章目录
前言1、使用root登陆mysql2、更新root账号密码3、开启root账号远程登陆权限4、开启3306端口访问权限
前言
今天接手一个项目,需要在本地用连接liunx服务器上的mysql数据库,就是开启远程链接,只知道服务器的root账号密码,不知道mysql的,记录一下吧
下面案例可供参考 1、使用root登陆mysql由于不知道root密码,登陆不了,修改/etc/my.cnf文件, 在**[Mysqld]**配置段下添加:skip-grant-tables 可以跳过mysql登陆时密码验证(好用!) 改好后重启mysql服务:/etc/init.d/mysql restart 用这个登陆:mysql -u root -p 需要密码直接回车 1、使用mysql数据库:use mysql; 2、更改root密码:update user set authentication_string = password(‘root’), password_expired = ‘N’, password_last_changed = now() where user = ‘root’; 注:我的mysql版本未5.7,密码字段为【authentication_string】,不同版本mysql字段不一样,可以使用【select * from user;】查看密码字段 3、开启root账号远程登陆权限1、使用mysql数据库:use mysql; 2、查看root账号权限:select user,host from user; 【exit;】退出mysql,查看3306端口状态:netstat -apn | grep 3306 将 bind-address = 127.0.0.1 改成 0.0.0.0 重启服务 service mysql stop service mysql start |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |