ubuntu18.04 上 mysql5.7 用户密码修改

# 查看默认用户密码
sudo vi /etc/mysql/debian.cnf
# 登录mysql
mysql -udebian-sys-maint -p
# 切换数据库
use mysql;
# 修改root 用户密码
UPDATE user SET plugin='mysql_native_password' WHERE user='root';
update mysql.user set authentication_string=password('rootpass') where user='root' and host='localhost';
flush privileges;
# 创建新用户
create user 'newuser'@'localhost' identified by 'newuser';
flush privileges;
# 修改登录权限
update user set host='%' where user='newuser';
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
添加 character_set_server = utf8
修改 bind-address         = 0.0.0.0
# 给newuser用户授权,授予newuser全部权限
grant all privileges on *.* to  'newuser'@'%' identified by 'newuser' with grant option;
flush privileges;

你可能感兴趣的:(mysql,数据库)