Setting root password in fresh mysql 5.7 installation

mysql 5.6 seems to have a new —random-passwords option for mysql_install_db, which lets me discover the root password:

But what can I do with mysql 5.5? The documentation suggests that the root password should be empty, but I cannot seem to connect with no password (or an empty password), so i cannot set a real root password:

I initialize the database like so:

I start the server like so:

I get this error:

asked Jan 2, 2013 at 18:09

You should be able to connect without a password by just doing this:

$ mysql -uroot

or you can do it the stubborn way:

UPDATE 2013-01-02 16

I am sorry, I overlooked the port number.

answered Jan 2, 2013 at 18:28

32 gold badges310 silver badges512 bronze badges

Try to run mkdir -p var tmp before mysql_install_db.

create mysql db failed in my situation.

Maybe the question’s cause is the same with mine.

answered Sep 11, 2013 at 7:10

I am trying to install mysql in a serving having CentOS Linux release 7.2.1511. Take a look to the process installation:

# sudo yum install mysql-server

I ran the mysql damon:

# sudo service mysqld start

Checking the service:

Here comes the problem driving me crazy. I want to set root password for the very first time, so I did:

# sudo mysql_secure_installation
// when password is required, I just type «enter key»

But the output: Securing the MySQL server deployment.

Googling the error, in 90% of cases, the solution is to call mysqld_safe —skip-grant-tables & command:

But mysqld_safe prompts an «command not found» error. I also tested with sudo mysqld —skip-grant-tables &, but it does not do anything. I will appreciate if you guide me to the right direction in order to set root password. Thank you in advance.

Дополнительно:  Common Latin and Greek Word Roots

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.

Дополнительно:  Draft-ietf-dnsop-ohta-shared-root-server-test-00

To show the available databases.

Creating a database.


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

When installing MySQL, you may noticed that it does not ask for a password. This become troublesome when you want to connect your application to MySQL database. In this article, I will show you on how to find MySQL default password.

Also, in case you have accidently put a password during installation process and can’t recall the password, you need to reset the password.

There is no way to view the password as it’s already written as hashed.

How To Reset MySQL Default Password

2. On the windows search box, search for services.msc and click to open.

3. Scroll down to all services with its status. Find MySQL services, right-click on it and click stop services.

4. Create a text file which contains the SQL statement in a single line as below:

Change MyNewPass to your new desired password.

5. Save it to a text file. For example, save it as C:

7. Start the MySQL with init_file system variable set to text file name created as below:

You may replace your MySQL installation location after cd command.


1. Open terminal.

2. Stop MySQL server.

sudo service mysql stop

sudo /usr/local/mysql/support-files/mysql.server stop

3. Start MySQL in safe mode.

sudo mysqld_safe –skip-grant-tables

4. Open another terminal and login as root by run below command.

mysql -u root

3. Once MySQL is logged in via terminal, run below queries.

which be looks like:

If you are using MySQL 5.7 and above you need to run command as below:

4. Now, you can exit MySQL safe mode.

If you received error ‘access denied’ you can run below command with the new password:

Дополнительно:  Video tdr failure Windows 10. Как исправить atikmpag. sys на синем экране

5. Start MySQL service again by run below command.

sudo service mysql start

What If Still Failed To Reset MySQL Default Password?

Thanks for reading this article. I hope you find it helpful.

Image: Jack Wallen

SEE: A fast and furious guide to MySQL database engines (TechRepublic)

A word of warning: Given the current state of attacks, across the landscape of IT, I highly recommend you using seriously strong passwords for your databases. Instead of using an easily memorized password, use a random password generator, and then, store that in a password manager. Be safer than safe.

With that said, let’s get to work.

How to set MySQL password for the first time

Do note, I will refer to MySQL with the idea that everything will work for both MySQL and MariaDB.

Where NEWPASSWORD is the password to be used. Now, when you log into MySQL, with the command mysql -u root -p, you will be prompted to enter the newly configured password.

Answer the presented questions, and your password will be set, making your database a bit more secure.

SEE: Password management policy (TechRepublic Premium)

How to change MySQL root user password

Where PASSWORD is the new password to be used. Save that file as ~/mysql-pwd.

Next, stop the MySQL daemon with the command:

sudo systemctl stop mysql

With the daemon stopped, issue the command:

sudo mysqld -init-file=~/mysql-pwd

Once your command prompt is returned, restart the MySQL daemon with the command:

sudo systemctl start mysql

How to recover your MySQL password

Where NEWPASSWORD is the new password to be used.

Restart the MySQL daemon with the command sudo service mysql restart. You should now be able to log into MySQL with the new password.

And that’s it. You can now set, reset and recover your MySQL password.

Оцените статью
Master Hi-technology
Добавить комментарий