mysql Ver 8.0.31-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
mysql Ver 15.1 Distrib 5.5.68-MariaDB, for Linux (x86_64) using readline 5.1
Restart the MYSQL server and continue installing Ezeelogin
Note: Empty/blank password means there is no password; hence anyone can log in as long as MySQL privileges have been granted.
To log in as a root user in Linux
If the password is not set up or you forgot or need to change your MySQL password, below is a guide on how to do set up/recover the password.
В Debian 9 пакет с MySQL сервером называется . Из него, по сути, устанавливается MySql сервер, который с некоторых пор зовется MariaDB. Имена бинарников, конфигурационных каталогов и файлов не поменялись — всё осталось как у MySql. Например, сам бинарник MySql-консоли как назывался , так и называется. Каталог настройки тоже не претерпел изменений:
Неужели ничего больше не изменилось? Конечно, изменилось. Например, раньше, при установке MySql сервера, запрашивался пароль для SQL-пользователя root. Теперь этого не происходит. И даже запуск команды:
Почему так произошло? Как задать пароль SQL-суперпользователя? Разработчики MariaDB решили, что теперь авторизация с сервером должна происходить не по паролю, а по токену. Поэтому в свежеустановленной MariaDB у пользователя root нет пароля.
Далее, чтобы упростить повествование, название MariaDB писаться не будет. В конце концов, это всего лишь название пакета и информационная строка в опции —version. Все будет написано так, как будто речь идет о MySql.
Вход в консоль управления
Чтобы зайти в консоль управления, необходимо из-под UNIX-пользователя дать команду:
mysql -u root -p
На вопрос «Enter password:» надо просто нажать Enter. Если вы дадите эту команду от обычного UNIX-пользователя, то получите ошибку:
В общем, c помощью этой команды происходит вход в консоль управления MySql под SQL-пользователем .
Задание пароля для пользователя root
Для задания пароля SQL-пользователя , следует активировать базу :
1 row in set (0.00 sec)
Видно, что у пользователя root отсутсвует пароль, а в плагинах прописан метод подключения через сокет. Задать пароль для root можно следующими командами:
Затем можно отключить плагин unix_socket, чтобы подключение к БД было возможно не только локально:
Вроде как данную настройку править не обязательно, потому что она дополняет режимы подключения, а не заменяет, но тут мнение экспертов в рунете расходятся.
После чего надо обновить привелегии пользователей:
После этих действий таблица пользователей должна выглядеть примерно так:
Далее надо проверить, как работает вход в консоль MySql с новым паролем. Выход из консоли:
# mysql -u root -p
Enter password: Вводим пароль (при вводе он не будет отображаться)
Welcome to the MariaDB monitor.
Все в порядке.
Теперь, после такой настройки, вход в консоль управления MySql под SQL-пользователем root будет возможен из bash-сессии любого UNIX-пользователя. Надо будет просто ввести пароль. Команда для входа всё та же:
$ mysql -u root -p
А нужно ли делать все эти настройки? Задавать пароль root? В принципе, нет. Вместо этого можно создать еще одного SQL-пользователя, у которого будет доступ к изменению только одной базы данных. И эта настройка наиболее правильна. Но мы же дилетанты, а не опытные БД админы, которым достаточно одной консоли. А для того, чтобы подключиться к mysql-серверу в качестве администратора с какого-нибудь внешнего GUI менеджера, придется задать пароль администратора.
Ever forgotten or just wanted to change your MySQL password? You’ve come to the right place – in this guide, we’ll walk you through how to set, change and recover your MySQL root password as well as other useful MySQL commands.
RunCloud uses MariaDB, an enhanced drop-in replacement for MySQL, as a database. MariaDB is a community-driven package by the original developers of MySQL, with the promise of future compatibility, hence, terminal commands and software tools for MySQL database can be used for MariaDB as well.
However, if you want to avoid any of these risks then SSH is the way to go. If you have no prior experience managing MySQL, don’t worry, with RunCloud, it is as easy as ABC.
First, you need a terminal to work on. On a Windows machine, you can download the PuTTY software. If you are on a Mac or Linux, there is already a built-in Terminal app installed.
The MySQL root password that is displayed on your terminal screen at the end of the RunCloud agent installation on your server (example below is installation on DigitalOcean) is meant to be kept for safekeeping elsewhere, but if you forgot to copy it down, you can still retrieve it.
Pic1: Keep the MySQL password somewhere safe!
Pic 2: Viewing the MySQL root password
How to Reset/Change MySQL Password
Pic 3: Resetting the MySQL root password
Other Basic MySQL Commands
Even though you can run some basic MySQL commands in the RunCloud control panel, it would not hurt to know how to do the same tasks in command line. Below are some of the basic commands that should get you going.
When you run the commands below, replace the database name of your choice at the DatabaseNameHere.
To show the available databases.
Creating a database.
CREATE DATABASE DatabaseNameHere;
DROP DATABASE DatabaseNameHere;
To use or operate on a particular database. The MySQL prompt will change to reflect the database name that you have specified.
Categories: Tutorials, Server Management, Tips & Tricks
SET MYSQL ROOT PASSWORD
What is Mysql default Password?
How to set Mysql root Password?
1. Stop Mysql Service.
2. Ensure mysqld dir exists and set the owner.
3. Start MySQL with —skip grant-tables& option
When the —skip-grant-tables option is used, anyone can connect to the database server without a password d with all privileges granted.
4. Login without a Password.
5. Reset the Root Password
6. After Resetting make sure all MYSQL processes are stopped before starting the service again.
7. Start Mysql service
Recover your MySQL password
1. Stop the MySQL server process using the command:
sudo service mysql stop
service stop MySQL
sudo mysqld_safe —skip-grant-tables —skip-networking &
Once you are done running all the commands mentioned above, proceed and restart the MySQL daemon using this command:
sudo service mysql restart
restart MySQL service
By now, you should be able to log into MySQL using the newly set password.
That’s all. We believe you are now in a position to set, reset, and recover your MySQL root password.
Then, input your passcode at the prompt. A MySQL shell will load.
For the sake of the tutorial, I will change the password to ‘Fosslinux as shown in the command line and output below:
open MySQL shell
After running the commands listed above, exit the MySQL shell by clicking CTRL + D on your keyboard or key in “exit” on the MySQL shell and click enter. You do not have to restart the MySQL service for you to log in using the command below:
At this point, you can now attempt to access MySQL with root again. In the terminal, key in:
login to MySQL as root
How to set up, change, and recover a MySQL root password
Please note: there have been many attacks across the IT landscape, thus necessitating very strong passwords, which I highly recommend for your databases. You can try out an unsystematic password generator, then save the password via the aid of a password manager.
Let’s carry on.
Setting the password for the first time
Typically, during the installation of MySQL, you are required to set an initial password. However, if this was not done while installing and setting up MySQL, you will first have to set up a password. Here is how to do that:
Where Fosslinux is the password that you will be using from now on, this means that every time you log into MySQL using the command mysql -u root -p, you will have to key in the password we have just configured.
MySQL secure installation
After setting up the MySQL root password for the first time, it is time to learn how to change it.
Changing the MySQL root user password
create new password
Where Fosslinux$11 is the new password that will be used. Remember to satisfy the current password policy by combining uppercase, lowercase, numeric and special characters.
Save the file as ~/mysql-pwd
sudo systemctl stop mysql
sudo mysqld -init-file=~/mysql-pwd
save MySQL password
sudo systemctl start mysql
Now that we have fruitfully learned how to change the newly created MySQL root password, it is time to learn how to recover a forgotten or lost MySQL root password.
The article further breaks down the steps to set up, change and recover a MySQL root password and set up the root password for the first time. Ensure to stick to all the processes provided in this article to avoid security breaches by using strong password combinations. We hope the article will be helpful. If yes, give a thumbs up via the comments section.