Mysql – How to change thesql username and password

MySQLpasswords

I have installed MySQL on my mac v10.8.5, with the default username='' and password=''.

How do I change these to username='root' and password='root'?

Best Answer

Follow thid step:

Stop MySQL

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

Start it in safe mode:

sudo mysqld_safe --skip-grant-tables

This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password:

mysql -u root

UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';

Change the lowercase password to what you want – with single quotes.

FLUSH PRIVILEGES;

 \q

Start MySQL

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

Reference