Ubuntu中MySQL登录、改密码及权限分配

1.切换目录cd /etc/mysql
2.打开文件sudo vi ./debian.cnf,记下user和password
3.启动MySQL服务sudo service mysql start
4.用刚才记下的user和password登录MySQLmysql -u debian-sys-maint -p
5.更改密码

use mysql;
SELECT user FORM user; #看看有哪些用户
update user set authentication_string=password('new password') where User='root'; #更改root用户的密码为new password
flush privileges;

6.或者给用户分配权限,这里的示例是给root用户分配
grant all privileges on *.* to 'root'@'localhost' identified by '123456' with grant option;

猜你喜欢

转载自blog.csdn.net/u013213111/article/details/88020824
今日推荐