当前位置: 首页 > news >正文

Ubuntu下配置并远程连接MySQL

1、安装mysql-server

apt update
apt install mysql-server

2、修改配置文件/etc/mysql/mysql.conf.d/mysqld.cnf

bind-address            = 0.0.0.0
mysqlx-bind-address     = 0.0.0.0

3、启动并设置服务为开机自启动

systemctl enable mysql.service --now

4、查看服务状态

systemctl status mysql.service

5、配置远程连接

(1)配置mysql_native_password插件,以允许用口令连接

本地登录数据库,执行以下命令

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '自行设置连接密码';FLUSH PRIVILEGES;

(2)修改mysql数据库的host主机,以允许远程连接

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changedmysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql> FLUSH PRIVILEGES;

(3)初始化mysql

mysql_secure_installation Press y|Y for Yes, any other key for No: yThere are three levels of password validation policy:LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  filePlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Please set the password for root here.New password: Re-enter new password: ……Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y- Dropping test database...
Success.- Removing privileges on test database...
Success.Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.All done! 

6、重启mysql服务

systemctl restart mysql

7、远程连接

使用navicat等连接工具就可以远程连接了。

http://www.dtcms.com/a/356157.html

相关文章:

  • 平安养老险深分开展“金融护航,安居鹏城”新市民金融服务宣传活动
  • Unity+URP+WebGL抗锯齿设置
  • MTK Linux DRM分析(二十二)- MTK mtk_drm_crtc.c(Part1)
  • PDF,HTML,md格式文件在线查看工具
  • CosyVoice win10启用记
  • 【mysql】SQL 中 IS 与 = 的区别:一个 NULL 值引发的思考
  • 编译esp32报错解决办法
  • 光谱相机多层镀膜技术如何提高透过率
  • [新启航]白光干涉仪在太阳能电池片栅线高度 3D 轮廓测量中的应用解析
  • 【C语言】递归
  • 屏随人动+视觉魔方+多样主题+智能留言,涂鸦Wukong AI 2.0助力打造爆款带屏云台相机
  • 从0开始学习Java+AI知识点总结-28.Linux部署
  • PDF 24 Tools, PDF编辑工具, PDF压缩, PDF转换, PDF删除, PDF加密, 添加水印
  • 创业灵感第一集
  • OpsManage:基于Django的企业级AWS云资源运维管理平台
  • 《零基础入门AI:YOLOv2算法解析》
  • Vue开发准备
  • 医疗AI时代的生物医学Go编程:高性能计算与精准医疗的案例分析(四)
  • OpenHarmony设备使用统计深度实战:从数据埋点到信息采集的全链路方案
  • 使用 Bright Data Web Scraper API + Python 高效抓取 Glassdoor 数据:从配置到结构化输出全流程实战
  • C++ 8.28
  • Dify学习
  • Python 正则表达式完全指南:从基础语法到实战案例
  • 深入理解文本向量嵌入(Vector Embeddings):原理、实践与应用场景
  • Linux---gdb和cgdb
  • UML状态图中entry/do/exit动作的深入解析与C/C++实现
  • 《深度讲解 C 语言动态内存:函数用法、错误规避与经典笔试题》
  • 同类软件对比(二):VS Code 与 PyCharm 的 Python 开发对比与使用建议
  • JavaScript初识:给小白的第一堂编程课
  • Day20 常见降维算法