ubuntu22.04安装mysql8

ubuntu22.04安装mysql8

为了更好的浏览体验,欢迎光顾勤奋的凯尔森同学个人博客http://www.huerpu.cc:7000/

#也可以访问https://dev.mysql.com/downloads/repo/apt/获取配置包
wget https://dev.mysql.com/get/mysql-apt-config_0.8.14-1_all.deb

#执行此安装配置包
dpkg -i mysql-apt-config_0.8.14-1_all.deb

#更新
apt-get update

#安装mysqlserver
apt-get install mysql-server

#安装mysqlclient
apt-get install mysql-client

#登陆mysql
mysql -uroot -p

#修改root密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY '123456';

#如果修改不成功,可以执行下面这一句
create user 'root'@'%' identified by '123456';

#授权所有操作权限给root
grant all privileges on *.* to 'root'@'%';

#创建一个hep用户,并授权所有操作权限
create user 'hep'@'%' identified by '123456';
grant all privileges on *.* to 'hep'@'%';

#刷新权限
flush privileges;

#退出
exit;

#使得mysql可以远程登陆
vim /etc/mysql/mysql.conf.d/mysqld.cnf
#注释掉这一行
#bind-address = 127.0.0.1

#重启mysql
service mysql restart;

#开放3306端口
ufw allow 3306

#查看3306端口是否被监听
netstat -anp | grep mysql

你可能感兴趣的:(Linux,mysql,数据库)