公众号:架构师与哈苏
关注公众号进入it交流群! 公众号:架构师与哈苏 不定时都会推送一些实用的干货。。。

方式一:使用skip-grant-tables

sudo apt-get update
sudo apt-get install mysql

# 跳过授权表验证
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
最后添加:
skip-grant-tables

# 重启
sudo systemctl restart mysql

mysql -uroot -p
回车进入myslq

FLUSH PRIVILEGES;

# 创建远程连接账号
CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password  BY '密码';

GRANT ALL ON *.* TO 'root'@'%';

# 修改本地localhost密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY '密码';

# 注释掉skip-grant-tables 和 bind
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf 
# skip-grant-tables
# bind-address          = 127.0.0.1

方式二:


sudo apt update
sudo apt install mysql-server

sudo mysql_secure_installation

# 直接登陆进去
sudo mysql

# 创建远程连接账号
CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password  BY '密码';

GRANT ALL ON *.* TO 'root'@'%';

# 修改本地localhost密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY '密码';

# 注释掉bind
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf 
# bind-address          = 127.0.0.1


posted on 2022-03-09 13:02  公众号/架构师与哈苏  阅读(93)  评论(0编辑  收藏  举报