【软件安装】在Ubuntu中安装mysql5.7

发布于:2024-11-28 ⋅ 阅读:(16) ⋅ 点赞:(0)

参考:cubuntu安装mysql5.6_mob649e81553a70的技术博客_51CTO博客

问题1:sudo apt install mysql-server-5.7 -y 若提示mysql-server 没有可安装候选

答:

sudo nano /etc/apt/sources.list

在开头加入:

#  阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

更新后即可安装:

sudo apt-get update

问题2:安装完成后,mysql -u root -p命令提示Access denied for user 'root'@'localhost'

强行登录

sudo mysql

问题3:如何设置mysql的开机启动

sudo systemctl enable mysql