ubuntu 安装 mysql-server

修改密码

1
2
3
use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;

另外一种修改密码

1
mysqladmin -u root -p password '密码'

查看默认用户名密码

1
sudo cat /etc/mysql/debian.cnf

远程登录

1
2
3
4
5
6
create user 'root'@'%' identified by '你自己的mysql密码';
grant all privileges on *.* to 'root'@'%';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你自己的mysql密码';
flush privileges;

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf