MySQL

ssh连接服务器

1
ssh username@ipaddress

登录

1
mysql -u root -p

修改密码

想修改密码,网上找到的指令,结果报错了

1
2
mysql> update user set password=password('新密码') where user='用户名';
ERROR 1054 (42S22): Unknown column 'password' in 'field list'

错误的原因是 5.7版本下的mysql数据库下已经没有password这个字段了,password字段改成了authentication_string

正确姿势:

1
2
3
4
5
6
7
8
9
10
mysql> update mysql.user set authentication_string=password('****') where user='****';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye
update user set authentication_string=password("*") where user="root";

cmd

1
2
3
show databases;

show tables;