10. MySQL Server
10. MySQL Server
Introduction
Requirements
1. A machine as MySQL server
2. A client machine
3. DNS server is turned on
4. Privileged access to your Ubuntu system as root or via sudo command is required
Outcomes
You will provide a MySQL server to persist the data and provide a query interface for it (SQL).
You use the MySQL client to send commands to any MySQL server; on a dedicated remote
machine.
1. Back to the www machine and install the mysql-server package as following:
2. After the installation, run the security script: (Can skip this step, because there are update been doing
on mysql.
sudo mysql_secure_installation
Note: This changes some of the less secure default options for things like remote root logins
and sample users.
3. Press Enter and answer yes to set up the Validate Password Plugin, which can be
used to test the strength of your MySQL password.
4. Type 0 and press Enter for Low level of password validation policy (p/s: use for
learning purpose)
5. Enter and then confirm a secure password of your choice. (p/s: recommend
"abc@123" for learning purpose.
8. Type y and press Enter to remove test database and access to it.
Note: This will set a password for the MySQL root user, remove some anonymous users and
the test database, disable remote root logins, and load these new rules so that MySQL
immediately respects the changes you have made.
sudo mysql
11. Check which authentication method each of your MySQL user accounts use with the
following command:
Note: You can see that the root user does in fact authenticate using the auth_socket plugin.
13. Reload the grant tables and put your new changes into effect:
14. Check the authentication methods employed by each of your users again to confirm
that root no longer authenticates using the auth_socket plugin:
Note: You can see in this example output that the root MySQL user now authenticates using
a password.
mysql> exit
The following will run your MySQL client with regular user privileges.
18. Then, grant your new user the privileges to all tables within the database, as well as
the power to add, change, and remove user privileges, with this command:
mysql> exit
mysql -u admin -p
mysql> exit
The following will create the remote connection from a dedication address (or machine).
bind-address = 10.0.2.13
mysql -u admin -p
26. Then, grant all tables within the database, as well as the power to add, change, and
remove user privileges, for user test1 from 10.0.2.11:
For an additional check, you can try connecting to the database using the
mysqladmin tool. For example, this command says to connect to MySQL as admin,
prompt for a password, and return the version:
31. After the installation, login to MySQL shell promt remotely using admin account: