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   zyp_java_net  阅读(51)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· DeepSeek “源神”启动!「GitHub 热点速览」
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示