美文网首页
ubuntun 16.04 mysql 修改密码和开放远程访问

ubuntun 16.04 mysql 修改密码和开放远程访问

作者: 蟠龙有悔 | 来源:发表于2019-06-26 08:38 被阅读0次

进入配置文件

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
// 忽略密码
skip-grant-tables
#
# 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

无密码进入mysql命令

~$ mysql      / mysql -u root
mysql> use mysql;
mysql> desc user;      // 列表字段
mysql> update user set authentication_string=password('123456')  where user='root';
// ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';  // 这一条命令没试过,有空试一试
mysql> flush privileges;
mysql> exit;

// 备注掉 `skip-grant-tables`

~$ sudo service mysql restart

列表字段的三种方法:
方法 1:DESC user;
方法 2:DESCRIBE user;
方法 3:SHOW COLUMNS FROM user;

相关文章

网友评论

      本文标题:ubuntun 16.04 mysql 修改密码和开放远程访问

      本文链接:https://www.haomeiwen.com/subject/xhkqcctx.html