8000 Ubuntu22.04安装 MYSQL 并使用 navicat 连接 · Issue #172 · holdyounger/ScopeBlog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Ubuntu22.04安装 MYSQL 并使用 navicat 连接 #172
Open
@holdyounger

Description

@holdyounger

Ubuntu22.04安装 MYSQL 并使用 navicat 连接

[toc]

安装

Ubuntu 安装 mysql 的教程网上一大堆。

sudo apt-get install mysql-server

配置

  1. 修改配置文件
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
  1. [mysqld] 添加 skip-grant-tables

修改配置

  1. 重启数据库
sudo systemctl restart mysql

# 或者

sudo service mysql restart

修改用户属性<a id="modifyuser"></a>

  1. 进入 mysql
sudo mysql -u root

# 切换到 mysql 数据库
use mysql;
  1. 更新用户密码
alter user root identified with mysql_native_password by &#39;Admin1234&#39;;

# 或者

update user set authentication_string=&#39;Admin1234&#39; where user=&#39;admin&#39;;

到此就可以使用用户登录了。

mysql -u root -p
  1. 补充,创建其他用户
CREATE USER &#39;username&#39;@&#39;host&#39; IDENTIFIED BY &#39;password&#39;;

授权远程使用

> 更改授权后,一定要执行 flush priviledges;

grant all on *.* to &#39;root&#39;@&#39;%&#39;;

执行上一步可能会报错,因为在 上一步 修改用户密码时,设置了地址为 localhost。所以这里不能直接授权其他主机访问,需要先把root账号的host修改为可以访问所有主机,再去授权。

  • 修改root账户
update user set host=&#39;%&#39; where user=&#39;root&#39;;

flush priviledges;
  • 授权远程使用
grant all on *.* to &#39;root&#39;@&#39;%&#39;;

flush priviledges;
  • 重启数据库
sudo systemctl restart mysql

# 或者

sudo service mysql restart

使用 navicat 连接数据库

> 如果出现连接时报错 1130-host ... is not allowed to connect to this MySql server。则说明是服务器端口权限没开放。简单改动可直接使用ufw命令。如下所示:
>
> sudo ufw allow 3306

如下图所示:

  • 连接名:随便起名,用来区分连接的数据库
  • 主机:192.168.0.102 为虚拟机的ip地址
  • 端口:3306,mysql默认端口
  • 用户名:root
  • 密码:密码

navicat

blog link Ubuntu22.04安装 MYSQL 并使用 navicat 连接

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0