How to Install MySQL 8.0 on Ubuntu 20.04

本文详细介绍了如何在Ubuntu 20.04上安装MySQL 8.0,包括启用MySQL PPA、安装MySQL、进行安全性配置以及连接到MySQL服务器等步骤。

Home - Ubuntu - How to Install MySQL 8.0 on Ubuntu 20.04

How to Install MySQL 8.0 on Ubuntu 20.04 2

How to Install MySQL 8.0 on Ubuntu 20.04

Leave a Comment / Ubuntu, Ubuntu Feed / By Ubuntu Server Admin / April 7, 2021

MySQL is the popular relational database management system used for storing structured data in table formats. It is open source database server uses SQL (Structured Query Language) statements for to interact with. The MySQL is freely available under the terms of the GNU General Public License.

This tutorial will help you to install MySQL 8 on Ubuntu 20.04 LTS Focal Linux systems.

Contents hide

1 Prerequisites

2 Step 1 – Enable MySQL PPA

3 Step 2 – Installing MySQL 8 on Ubuntu

4 Step 3 – Secure MySQL Installation

5 Step 4 – Connect to MySQL

6 Conclusion

6.1 Share this:

6.2 Related

Prerequisites

You must have a running Ubuntu 20.04 LTS system with sudo privileged account access. Next, login to your system and open a terminal.

ssh ubuntu@remote.host 

Run below commands to upgrade the current packages to the latest version.

sudo apt update && sudo apt upgrade 

Step 1 – Enable MySQL PPA

MySQL team provides official MySQL PPA for Ubuntu operating systems. You can download and install the package on your Ubuntu 18.04 system, which will add PPA file to your system. Run below command to enable PPA.

wget http://repo.mysql.com/mysql-apt-config_0.8.10-1_all.deb 
sudo dpkg -i mysql-apt-config_0.8.10-1_all.deb 

The installer will prompt you to set default repository for the MySQL version. Make sure the MySQL-8 is set in currently selected. You can change this by navigating to line and press enter.

mysql change apt configuration

Once the properly version is selected move curser to last row “Ok” using keyboard up/down keys. Press enter to continue process.

In case you select wrong version. Execute dpkg-reconfigure mysql-apt-config command after package installation to get this window again.

Step 2 – Installing MySQL 8 on Ubuntu

Your system is ready for the MySQL installation. Follow the below commands to install MySQL 8 on a Ubuntu 20.04 Linux system.

  1. Add GPG Key – Run the following commands to install MySQL on Ubuntu 18.04 system.
    sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 8C718D3B5072E1F5 
    
  2. Update cache – Execute below command to update apt cache on your system.
    sudo apt update  
    
  3. Install MySQL – finally install the MySQL server packages.
    sudo apt install mysql-server 
    

The installation process will prompt for the root password to set as default. Input a secure password and same to confirm password window. This will be MySQL root user password required to log in to MySQL server.

MySQL on Ubuntu 18.04

MySQL on Ubuntu 18.04

Step 3 – Secure MySQL Installation

Execute the below command on your system to make security changes on your Database server. This will prompt some questions. The do the high security provide all answers to yes.

sudo mysql_secure_installation 

Here you can enable/disable validate password plugin, Set required strength for passwords, remove anonymous users, disallow root login remotely, Remove test database and access to it and reload the reload privileges after applied changes.

See the below output and action taken by me:

Securing the MySQL server deployment.

Enter password for user root:

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.

Estimated strength of the password: 50
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password: ****************

Re-enter new password: ****************

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

Step 4 – Connect to MySQL

The MySQL server has been installed on your system. Now connect to the MySQL database using the command line. Use root account password set in above step.

 mysql -u root -p 

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 9
Server version: 8.0.23 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql>

Conclusion

After completing this tutorial, You have installed MySQL 8 on Ubuntu 20.04 Linux system. Even you can access the MySQL from terminal, you can also install phpMyAdmin to work with it.

The production users recommended to schedule database backup on a regular interval. This script will help you to schedule MySQL database backup and copy them to remote locations.

The post How to Install MySQL 8.0 on Ubuntu 20.04 appeared first on TecAdmin.

Share this:

Ubuntu 20.04上安装Visual Studio Code可以通过多种方式实现,以下是最常用的几种方法: ### 方法一:通过官方APT仓库安装 1. 首先,确保系统已经更新到最新状态: ```bash sudo apt update && sudo apt upgrade ``` 2. 添加Microsoft的GPG密钥以验证下载的完整性: ```bash wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg sudo install -o root -g root -m 644 packages.microsoft.gpg /usr/share/keyrings/ ``` 3. 将VS Code仓库添加到APT源列表中: ```bash echo "deb [arch=amd64 signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list ``` 4. 更新APT包索引并安装Visual Studio Code: ```bash sudo apt update sudo apt install code ``` 这种方法安装的版本会随着系统的更新而自动更新[^2]。 ### 方法二:通过下载.deb包安装 1. 访问[Visual Studio Code官网](https://code.visualstudio.com/)下载页面,选择适合Ubuntu的`.deb`安装包。 2. 使用`wget`或浏览器下载`.deb`文件后,可以使用以下命令安装: ```bash sudo dpkg -i <path_to_downloaded_file>.deb ``` 如果遇到依赖问题,可以运行`sudo apt --fix-broken install`来解决。 ### 方法三:通过Snap商店安装 1. Snap是Ubuntu自带的一种软件包格式,可以直接通过它来安装软件。使用以下命令安装VS Code: ```bash sudo snap install --classic code ``` ### 安装中文输入法支持 如果计划在VS Code中使用中文输入法,需要额外配置IBus作为输入法框架,并确保VS Code能够正确识别中文输入。具体步骤包括: 1. 安装IBus及其相关组件: ```bash sudo apt install ibus ibus-pinyin ``` 2. 在系统设置中启用IBus作为默认输入法框架,并添加中文输入源。 3. 对于某些情况下VS Code可能无法直接支持中文输入的问题,可以尝试通过修改VS Code的启动参数来解决,例如添加`--enable-ime`参数启动VS Code。 以上方法可以帮助您在Ubuntu 20.04上成功安装并配置Visual Studio Code,确保其能够满足日常开发需求,包括对中文输入的支持[^2]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值