ubuntu22 mysql 8.0.33
一、安装
下载安装
sudo apt install mysql-server -y
查看版本
mysql --version
mysql Ver 8.0.33-0ubuntu0.22.04.2 for Linux on x86_64 ((Ubuntu))
查看是否运行
sudo systemctl status mysql
Active: active (running) since Thu 2023-05-18 19:53:54 CST; 2h 41min ago
修改密码
进入mysql(默认无密码)
sudo 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 -A
Database changed
查看
select host,user from user;
返回结果:
±----------±-----------------+
| host | user |
±----------±-----------------+
| localhost | debian-sys-maint |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
±----------±-----------------+
5 rows in set (0.26 sec)
改为可从任何主机访问数据库
update user set host='%' where user='root';
返回结果:
Query OK, 1 row affected (0.22 sec)
Rows matched: 1 Changed: 1 Warnings: 0
查看
select host,user from user;
返回结果:
±----------±-----------------+
| host | user |
±----------±-----------------+
| % | root |
| localhost | debian-sys-maint |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
±----------±-----------------+
5 rows in set (0.00 sec)
改密码
show databases;
show tables;
select host,user from user;
alter user 'root'@'%' identified with mysql_native_password by 'master$12342023';
flush privileges;
退出
exit
测试登录
mysql -u root -p 123456
退出
exit
开启远程访问
改
vim /etc/mysql/mysql.conf.d/mysqld.cnf
将以下地址均改为 0.0.0.0
bind-address = 127.0.0.1
mysqlx-bind-address = 127.0.0.1
重启mysql
sudo systemctl restart mysql
测试:使用navicat连接
二、卸载
使用 apt-get 命令卸载 MySQL:
sudo apt-get remove --purge mysql-server mysql-client mysql-common
删除 MySQL 的配置文件和数据:
sudo rm -rf /etc/mysql/ /var/lib/mysql/
清除 MySQL 相关的依赖:
sudo apt-get autoremove
清除残留文件和目录:
sudo find / -iname 'mysql*' -exec rm -rf {} ;
参考: unbuntu如何彻底删除mysql?
————————————————
posted on 2023-07-28 08:29 zyp_java_net 阅读(51) 评论(0) 编辑 收藏 举报
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· DeepSeek “源神”启动!「GitHub 热点速览」
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器