ubuntu18.04下安装MySQL5.7

更新源

sudo apt update

安装mysql

sudo apt install mysql-server

使用sudo mysql进入数据设置root账户的密码和权限

sudo mysql

修改密码

show databases;
use mysql;
show tables;
update user set plugin='mysql_native_password' where user='root';
update user set authentication_string=PASSWORD('你要修改的密码') where user=‘root’;
FLUSH PRIVILEGES;   # 刷新权限
\q   # 退出

重新进入mysql

mysql -u root -p
grant all on *.* to root@'%' identified by '123456';  # 为root用户授权

修改远程访问

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
:set nu  # 大于在43行左右
注释掉# bind-address = 127.0.0.1
# 重启
sudo service mysql restart
posted @ 2020-12-15 18:06  我在路上回头看  阅读(58)  评论(0编辑  收藏  举报