Initial MySQL root user account

After finishing my latest Drupal installation, I installed a MySQL database on my Linux server using yum, and then my mind went blank -- I couldn't remember how to create the initial MySQL “root” user (i.e., the initial MySQL user account).

Still unable to remember how to do this, I went ahead and started the MySQL server from my Linux root prompt just to make sure it was installed okay, like this:

# service mysqld start

when I saw the output from this MySQL startup command, it showed exactly what I needed to do to create the initial MySQL user.

Creating the initial MySQL root user account

Skipping some of the output for now, the output from the service mysqld start command showed the following information, which is exactly what I need to create my MySQL root user account:

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h dbserver.onemansalaska.com password 'new-password'

Of course you want to replace 'new-password' with the actual password you want to use for the MySQL root account.

Also, the second mysqladmin command is only needed if you're going to access your MySQL server over a network connection. If you need this capability, replace the database server name shown (dbserver.onemansalaska.com) with your own hostname.

In my case, this helpful output from the service mysqld start was exactly what I needed to finish my MySQL installation (and then finish my Drupal / MySQL database installation).

Complete "service mysqld start" output

For the record, the complete output from the service mysqld start command looks like this:

# service mysqld start

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h dbserver.onemansalaska.com password 'new-password'

See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
                                                           [  OK  ]
Starting MySQL:                                            [  OK  ]

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.