MySql 5.7 first setup, change root password and password length

After installing mysql-server (v5.7) on Ubuntu 18.04 for the first time, you will need to set up a separate user and password for it. To easily operate mysql on the local machine.

1. mysql installation :

sudo apt-get install mysql-server

2. User setup :

sudo mysql_secure_installation

mysql_sequre

For the local machine, LOW parameters were enough for me. It then asks for a password for the root user . Enter a password that is convenient for you and repeat it. Since we will change it in the future, I entered the root password (for some reason I missed it, despite the LOW validation). All other steps worked for me and I pressed Y to continue.

3. The first login from the console under the superuser :

sudo mysql

Should start up in mysql. Next, we check the users that are:

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

users mysql We see the presence of the root user , but he does not have a password.

Since I need the root password to have root:root access, I'll have to resort to changing the length of the allowed password.

SET GLOBAL validate_password_length= 4 ;

4 - length of the password allowed by the validator.

If a non-LOW validation level was selected, here is a description of the parameters in more detail .

4. Change password by request :

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

For the changes to take effect:

FLUSH PRIVILEGES;

With the request described above, we check whether everything has taken effect.

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

Проверка пароля юзера

The root user data has changed. Exit:

exit

and try to connect to mysql by root:root :

mysql -uroot -proot

проверка root mysql

If allowed, then our work was successful.

Source 1 Source 2

4235 0

Comments

Be the first to review this item. Share your rating and review so that other customers can decide if this is the right item for them.
You have to log in to leave a comment. Sign in

Similar articles

Mysql database of tires and disks

Base of automobile tires and disks. The database contains: manufacturer, model, year, modification, PCD, diameter, nut, tire and wheel factory sizes, possible replacement options, tire and wheel tuning. There are no trucks in the database.

Disabling sql_mode=only_full_group_by in mysql 5.7 ubuntu 18.04

What to do if the error SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'db.books' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by