Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

StepAction

1) Execute the following instruction sequence:


Code Block
languagebash
sudo apt update
sudo apt install mysql-server


2) Securing

  1. choose a password for root
  2. eliminate the anonymous user
  3. allow remote root connection
  4. deletion of the test board
  5. refill of the privileges table


Code Block
languagebash
sudo mysql_secure_installation


Code Block
languagetext
linenumberstrue
Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

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: 1
Please set the password for root here.

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) : no

 ... skipping.
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! 


3) Setting user authentication and privileges

Warning

change-root-password must contain the password defined in step 2



Code Block
languagebash
sudo mysql
SELECT user,authentication_string,plugin,host FROM mysql.user;


Code Block
languagebash
+------------------+-------------------------------------------+-----------------------+-----------+
| 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 | *D9DEF051BA53BF5AC0AD114CB5A4DA80B38C83FE | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)


Code Block
languagebash
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'change-root-password';
FLUSH PRIVILEGES;
exit


4) Testing Authentication

Mysql now requires you to enter a password for root


Code Block
languagebash
sudo mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


Code Block
languagebash
sudo mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.28-0ubuntu0.18.04.4 (Ubuntu)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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>


5) create a VIVO user for local and remote access

Warning

change-root-password must contain the password for the vivo user



Code Block
languagebash
sudo mysql -u root -p
Enter password: 
mysql>
CREATE USER 'vivo_i18n'@'localhost' IDENTIFIED BY 'change-root-password';
CREATE USER 'vivo_i18n'@'%' IDENTIFIED BY 'change-root-password';


6) Create the DB needed for VIVO


Code Block
languagebash
CREATE DATABASE vivodb_i18n CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT ALL PRIVILEGES ON vitrodbvivodb_i18n.* TO 'vivo_i18n'@'localhost';
GRANT ALL PRIVILEGES ON vitrodbvivodb_i18n.* TO 'vivo_i18n'@'%';


7) Confirm the installation


Code Block
languagebash
titleList user content
SELECT user,authentication_string,plugin,host FROM mysql.user;


Code Block
titleResult
+------------------+-------------------------------------------+-----------------------+-----------+
| user             | authentication_string                     | plugin                | host      |
+------------------+-------------------------------------------+-----------------------+-----------+
| root             | *711841F70B99BE5C909F7990576BF5864330C88E | mysql_native_password | localhost |
| mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *1E7991B7DEC6D1826ECFF03586E179300A3B8BBE | mysql_native_password | localhost |
| vivo_i18n        | *711841F70B99BE5C909F7990576BF5864330C88E | mysql_native_password | localhost |
| vivo_i18n        | *711841F70B99BE5C909F7990576BF5864330C88E | mysql_native_password | %         |
+------------------+-------------------------------------------+-----------------------+-----------+
6 rows in set (0.00 sec)


Code Block
languagesql
titleList the databases
SHOW DATABASES;


Code Block
titleResult
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| vivodb_i18n        |
+--------------------+
5 rows in set (0.00 sec)


...