受欢迎的博客标签

How To Install and uninstall reinstall Mysql on Ubuntu 18.04(vultr)

Published

 Install MySQL

os:Ubuntu 18.04.3 LTS

# lsb_release -a
LSB Version:	core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04
Codename:	bionic

Use apt-get to install MySQL. The installer creates a systemd init script that runs MySQL as daemon on system startup. Follow the installation instructions for Ubuntu as follow:

sudo apt update
sudo apt install mysql-server

output

Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]         
Get:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]                     
Fetched 252 kB in 0s (531 kB/s)                                                                  
Reading package lists... Done
...
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service -> /lib/systemd/system/mysql.service.
Setting up mysql-server (5.7.41-0ubuntu0.18.04.1) ...

sudo systemctl status mysql.service

output

 mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2023-04-26 16:50:10 UTC; 9min ago
 Main PID: 22937 (mysqld)
    Tasks: 28 (limit: 1104)
   CGroup: /system.slice/mysql.service
           `-22937 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid

 

Test  MySQL on Ubuntu 18.04(vultr)

step 1:

sudo mysql
mysql>SELECT user,authentication_string,plugin,host FROM mysql.user;

output

Output
+------------------+-------------------------------------------+-----------------------+-----------+
| user             | authentication_string                     | plugin                | host      |
+------------------+-------------------------------------------+-----------------------+-----------+
| root             |                                           | auth_socket           | localhost |
| mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *CC744277A401A7D25BE1CA89AFF17BF607F876FF | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)

 

Reinstall

To recreate it, first uninstall using purge to remove even configuration files and records:

then reinstall:

 

https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/