进入配置文件
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;
网友评论