Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find my host and username on mysql?

I need to open my database through PHP. But I need to know my username and the name of my host (e.g. localhost), and I don't know them.

When I used mysql and did my database, it just asked me directly for a password.

How do I find my host and username on mysql?

like image 219
Audel Avatar asked Feb 25 '10 16:02

Audel


2 Answers

type this command

select CURRENT_USER();

You will get the username and server

like image 59
d-coder Avatar answered Oct 25 '22 18:10

d-coder


The default username is root. You can reset the root password if you do not know it: http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html. You should not, however, use the root account from PHP, set up a limited permission user to do that: http://dev.mysql.com/doc/refman/5.1/en/adding-users.html

If MySql is running on the same computer as your webserver, you can just use "localhost" as the host

like image 40
adharris Avatar answered Oct 25 '22 18:10

adharris