ubuntu22.04在线安装MySQL8

ubuntu22.04在线安装MySQL8

wget https://repo.mysql.com//mysql-apt-config_0.8.25-1_all.deb

#输入这条命令,然后选择OK
sudo dpkg -i mysql-apt-config_0.8.25-1_all.deb

apt update 

#安装
apt-get -y install mysql-server

#输入密码,两次
#然后选择第二个,Use Legacy Authentication Method 

#查看状态
systemctl status mysql

#登录MySQL
mysql -uroot -p

#修改密码并设置访问主机
select host , user , plugin ,authentication_string from mysql.user;

ALTER USER 'root'@'localhost' IDENTIFIED BY 'admin123';
flush privileges;

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin123';
flush privileges;

update mysql.user set host = '%',plugin='mysql_native_password' where user='root';
flush privileges;

quit;

#重启mysql
systemctl restart mysql

#开放3306端口
ufw allow 3306

你可能感兴趣的:(Linux,mysq,ubuntu22,ubuntu22.04)