Monday 31 January 2022

How to install MySQL shell on Ubuntu

MySQL shell is MySQL DB client. mysqlsh (in Windows, that's mysqlsh.exe) is a successor of mysql client. [see more here]
 
In this tutorial I want to share my experience with installing it on my Ubuntu.  

Let's first check if it is installed already:

$ mysqlsh
bash: /usr/bin/mysqlsh: No such file or directory
 
We can now try to install it.

Update package information for the MySQL APT repository:

$ sudo apt-get update
...
 
Update the MySQL APT repository configuration package:

$ sudo apt-get install mysql-apt-config
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package mysql-apt-config


This means that we don't have MySQL APT repository configuration package installed (MySQL APT repository is not in system's software repository list). 

We need to go to download page for the MySQL APT repository at https://dev.mysql.com/downloads/repo/apt/ and download it:



Now we can install the downloaded release package:

$ sudo dpkg -i mysql-apt-config_0.8.22-1_all.deb
Selecting previously unselected package mysql-apt-config.
(Reading database ... 341402 files and directories currently installed.)
Preparing to unpack mysql-apt-config_0.8.22-1_all.deb ...
Unpacking mysql-apt-config (0.8.22-1) ...
Setting up mysql-apt-config (0.8.22-1) ...
Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config)
OK

We can now re-try the initial steps:

 
$ sudo apt-get update
...
Get:4 http://repo.mysql.com/apt/ubuntu focal InRelease [12.9 kB]                                                                                                 
...
Reading package lists... Done
 
$ sudo apt-get install mysql-shell
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed
  mysql-shell
0 to upgrade, 1 to newly install, 0 to remove and 25 not to upgrade.
Need to get 13.9 MB of archives.
After this operation, 109 MB of additional disk space will be used.
Get:1 http://repo.mysql.com/apt/ubuntu focal/mysql-tools amd64 mysql-shell amd64 8.0.28-1ubuntu20.04 [13.9 MB]
Fetched 13.9 MB in 5s (2,905 kB/s)      
Selecting previously unselected package mysql-shell:amd64.
(Reading database ... 341407 files and directories currently installed.)
Preparing to unpack .../mysql-shell_8.0.28-1ubuntu20.04_amd64.deb ...
Unpacking mysql-shell:amd64 (8.0.28-1ubuntu20.04) ...
Setting up mysql-shell:amd64 (8.0.28-1ubuntu20.04) ...
 
To verify that MySQL shall was successfully installed:
 
$ mysqlsh
MySQL Shell 8.0.28

Copyright (c) 2016, 2022, 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 '\?' for help; '\quit' to exit.
 MySQL  JS > \quit
Bye!

To check its version:

$ mysqlsh --version
mysqlsh   Ver 8.0.28 for Linux on x86_64 - for MySQL 8.0.28 (MySQL Community Server (GPL))



To uninstall it:
 
$ sudo apt-get remove mysql-shell
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED
  mysql-shell
0 to upgrade, 0 to newly install, 1 to remove and 25 not to upgrade.
After this operation, 109 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 348074 files and directories currently installed.)
Removing mysql-shell:amd64 (8.0.28-1ubuntu20.04) ...
 


No comments: