昨天刚刚安装了MYSQL,玩着挺Happy的,今天就链接不上了,报错是:

root用户没有权限

翻阅了一些文章,看着不太方便,我简单归纳一下:

一、添加账户

账户是:test;密码是:123456

insert into mysql.user(Host,User,Password,ssl_cipher,x509_issuer,x509_subject) values("localhost","test",password("123456"),'','',''); 

登录成功之后,发现没有目标数据库的权限,接下来:

二、赋给权限

grant all privileges on mydays.* to test@192.168.1.102 identified by '1234';

三、重新登录

mysql -h192.168.1.102 -utest -p'1234'

结果:

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mydays             |
| test               |
+--------------------+
3 rows in set (0.01 sec)