I have mysql installed on my Mac and when i check the system preferences it shows that it is running.
When, while trying to follow a tutorial, I try to create a database
mysql> create database tinyclone;
I get this error
mysql> create database tinyclone;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'tinyclone'
Before creating the database, the author of the book does
mysql –u <username> -p <password>
However, I don’t know my username, and I’m not 100% sure I know my password either.
I tried to do
sudo create database tinyclone;
and I got a different error message. Not sure what the problem with my syntax was
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sudo create database tinyclone' at line 1
Question, so that I can follow along with the book’s author, anyone know how I can find out my mysql username and password?
You’re not logged in as any user (hence the ”@’localhost’ bit). As others have suggested, try doing
mysql -uroot -prootormysql -uroot.There is (almost) always a ‘root’ user created by default, usually with no password, unless you specified one when initially installing/configuring mysql.
sudois not an SQL command. You cannot use it inside mysql. Instead log into sql with the ‘root’ user.Also, please note that the mysql root user is not the same as your computer’s root user.