ubuntu20.04 安装 mysql8.0.27
安装mysql
$ sudo apt update
$ sudo apt install mysql-server
进行初始化配置$ sudo mysql_secure_installation
查看MySQL版本
$ mysql --version
查看MySQL运行状态systemctl status mysql.service
进行连接$ sudo mysql -u root -p
$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
打开文件修改bind-address=0.0.0.0
重启MySQL服务$ sudo systemctl restart mysql.service
连接MySQL
$ sudo mysql -u root -p
创建远程连接账户并授权
mysql> use mysql;
mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'Movies123.';
mysql> grant all privileges on *.* to 'root'@'%';
如果远程连接时报错plugin caching_sha2_password could not be loaded,执行
mysql> alter user 'root'@'%' identified with mysql_native_password by 'Movies123.';
本地代码链接,改密码方式:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Movies123.
';
刷新权限
mysql> FLUSH PRIVILEGES;
查看用户
mysql> select host, user, authentication_string, plugin from user;
使用Navicat远程连接