Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

tables and creates a MySQL root user.


CAUTION
The MySQL data directory needs to be owned by the user that owns the
MySQL process, most likely mysql. (You might need to change the
directory’s owner by using the chown command.) In addition, only this
user should have any permissions on this directory. (In other words, you
should set the permissions to 700 by using chmod.) Setting up the data
directory any other way creates a security hole.

Running mysql_install_db should generate output similar to the
following:


Click here to view code image
matthew@seymour:~$ sudo mysql_install_db
Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv table
Preparing columns_priv table
Installing all prepared tables
020916 17:39:05 /usr/libexec/mysqld: Shutdown Complete
...


This command prepares MySQL for use on the system and reports helpful
information. The next step is to set the password for the MySQL root user,
which is discussed in the following section.


CAUTION
By default, the MySQL root user is created with no password. This is one
of the first things you must change because the MySQL root user has access
to all aspects of the database. The following section explains how to change
the password of the user.

Setting a Password for the MySQL Root User


To set a password for the root MySQL user, you need to connect to the
MySQL server as the root MySQL user; you can use the command mysql -
u root to do so. This command connects you to the server with the MySQL
client. When you have the MySQL command prompt, issue a command like
the following to set a password for the root user:


Click here to view code image
mysql> SET PASSWORD FOR root = PASSWORD("secretword");

Free download pdf