Ubuntu18.04安装MySQL

目的:主力机目前使用的系统是Ubuntu18.04桌面系统,记录下MySQL的安装过程。

MySQL的删除

sudo apt purge mysql-*
sudo rm -rf /etc/mysql/ /var/lib/mysql
sudo apt autoremove
sudo apt autoclean

MySQL安装

# 1、更新apt包索引
sudo apt update
# 2、安装默认安装包
sudo apt install mysql-server
# 3、运行安全脚本,做一些配置
sudo mysql_secure_installation


补充说明:安装完后root用户无法登录,故创建root用户

MySQL安装完建root用户

Ubuntu18.04安装 MySQL不会弹出设置账号密码的框,会自己默认设置好账号密码,配置文件在/etc/mysql/debian.cnf

使用此账号登录创建root用户

-- 更新root用户
update mysql.user set authentication_string=password("123456") where user="root";
-- 消除警告
update mysql.user set plugin="mysql_native_password";
-- 更新权限
flush privileges;

参考

https://www.jianshu.com/p/4b691bbe40a3
https://baijiahao.baidu.com/s?id=1626805903141392082&wfr=spider&for=pc
https://www.jianshu.com/p/ca22263ce97f

原文地址:https://www.cnblogs.com/kayj/p/12019819.html