Home  >  Article  >  Database  >  How to configure mysql8.0 in ubuntu20.04

How to configure mysql8.0 in ubuntu20.04

WBOY
WBOYforward
2023-06-03 12:48:051872browse

1 Installation

1.1 Download

wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb

1.2 Installation

dpkg -i mysql-apt-config_0.8.22-1_all.deb

Selection items will appear during the installation process. Use the up and down keys to select OK to continue the installation

How to configure mysql8.0 in ubuntu20.04

1.3 Install MySQL Server

Update apt software source

apt-get update

Install MySQL Server

apt-get install mysql-server

1.4 Common commands

# 查看服务状态
service mysql status
# 停止服务
service mysql stop
# 启动服务
service mysql start
# 重启服务
service mysql restart
#端口查看
netstat -anp | grep mysql

2 Configure external network access

2.1 View port

netstat -an|grep 3306

How to configure mysql8.0 in ubuntu20.04

2.2 Modify configuration file

cd etc/mysql/mysql.conf.d
#打开配置文件
sudo vim mysqld.cnf

Delete port = 3306 comment

How to configure mysql8.0 in ubuntu20.04

Comment bind-address = 127.0.0.1

How to configure mysql8.0 in ubuntu20.04

2.3 Modify root password

# 根据提示进行输入,问Y/N时不会就y吧
mysql_secure_installation

2.4 Modify user

# 进入mysql服务台 如果要输密码直接回车即可
mysql -h 127.0.0.1 -u root -p
#选择mysql数据表
use mysql;
# 更改root用户的访问权限
update user set host='%' where user='root';
#开放root用户所有权限
grant all privileges on *.* to 'root'@'%' identified by '你的root账户密码';
#展示user表的两个字段
select host,user from user;

How to configure mysql8.0 in ubuntu20.04

Ps: Don’t forget to release the firewall of the cloud host

The above is the detailed content of How to configure mysql8.0 in ubuntu20.04. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete