查看mysql账号密码

  1. sudo cat /etc/mysql/debian.cnf

修改

  1. sudo vim /etc/mysql/debian.cnf

完事需要重启

主机无法链接mysql

查看/etc/mysql/mysql.conf.d/mysqld.cnf

  1. # localhost which is more compatible and is not less secure.
  2. bind-address = 127.0.0.1
  3. #

修改写入权限

  1. sudo chmod 777 mysqld.cnf

把上面的改为

  1. # localhost which is more compatible and is not less secure.
  2. # bind-address = 127.0.0.1
  3. #

改回原来权限

  1. sudo chmod 644 mysqld.cnf

重启

mysql 链接没有权限

image.png

  1. # 按照下面逐步完成即可
  2. mysql -u root -p
  3. use mysql;
  4. update user set host = '%' where User = 'root';
  5. flush privileges;