How to set root password for aws ec2 with mysql preinstalled?

17,896

Solution 1

Amazon EC2 never sets a password for the "mysql" root user. So you can either a) use "mysql -u root -p" and then press the "Enter" key when asked for password. Or, b) use "sudo mysql"

On my EC2 instance, both methods are working.

Solution 2

Configuring newly installed MySQL Server

To update the password of root user do the following:

  • mysqladmin -u root password [your_new_pwd]

To create a database do the following:

  • mysqladmin -u root -p create [your_new_db]

Then restart your server

  • service mysqld start
Share:
17,896

Related videos on Youtube

jon
Author by

jon

Updated on September 18, 2022

Comments

  • jon
    jon over 1 year

    I have an EC2 instance with mysql preinstalled. I need to now use mysql - therefore I need a root password, however when I try and run:

    mysqladmin -u root password [aBc123DeF]
    

    I get the following error:

    mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user 'root'@'localhost' (using password: NO)'
    

    Thanks to any responders. J