As you probably know, MySQL is a database server. That means, you need a client to connect to a MySQL server. The mysql
command line program you are using is such a client.
As with many systems, a MySQL server has its own user accounts and privileges. So if you connect a client to a MySQL server, you have to provide an username and (almost always) a password. If you don't provide the mysql
with an username, it assumes you want to use the UNIX/Linux username you are logged into your server as. For example, if you are logged into your server as 'joe', mysql
tries to use the MySQL user of the same name, which is 'joe@localhost'. As you see, MySQL user accounts always contain the hostname you are connecting from. That is automatically added.
If you want to connect to your MySQL server as the user 'joe@localhost', you can do
mysql -u joe
With this, MySQL assumes that the MySQL server is running on the same machine as the client (therefore, the 'localhost' hostname is automatically added) and 'joe@localhost' does not have a password set.
If the desired MySQL user account has a password set, you can have the mysql
client ask for it with
mysql -u joe -p
And, for the sake of completeness, if you want to connect to a MySQL on another machine as the client runs on, you can do something like
mysql -h my-mysql-server.com -u joe -p
In your special case, the MySQL user account the mysql
client connects to the MySQL server as does not have the necessary privileges to create a new database. You need to connect as a MySQL user that has these privileges. Which user account that is depends on how you set the MySQL server up.