Jump to content

Can't CREATE DATABASE and more problems with Laragon and MySQL


LeonLatex

Recommended Posts

MySQL uses a scheme where every user has a name & host component.  So for example:  root@localhost.  It is possible to have wildcards for the hostname component, but typically accounts will start out being constrained to localhost.  It's important to understand how this works, because permissions are then granted to a specific user@host combination, and if later someone adds a wildcard account for the combination  (for example  --  'user@%' that user will not inherit/adopt the permissions of the existing user@localhost account.

There will be a "root" level account for mysql that has all rights.  By default, this is usually root@localhost.  This user can create new users, change passwords, create databases and grant permissions for new or existing users to that database.

Typically what is done for security purposes is:

  • root level account creates a database
  • root level account creates/GRANT access to the database for that user.  Application will use this user to work with the database.

Some of the specifics of the syntax of the SQL used to create a new user or assign it a password have changed over time between mysql and mariadb versions.  Tools that were dependent on the syntax or specific password scheme may no longer work properly given a specific version.

What your screenshot shows is that laragon is logging you in a specific configured user, that was created and given access to a database.  That user does not have access to create a new database.  This is a typical setup.

You need to login to mysql as the "root" user that laragon setup initially.  I think it is probably still 'root@localhost'.  Apparently by default the root password was unset.  This SO thread talks about this, although it is a 4 year old thread:  https://stackoverflow.com/questions/50214540/laragon-never-use-mysql-password

 

Link to comment
Share on other sites

You are trying to connect as a user other than the default root account. (122387_chapterofhate@localhost) The account you are connecting with does not have the permissions needed to do what ever it is you are trying to do.

Laragon is a local development wamp. There is really no reason you need to be creating and using any other MySQL users except maybe for learning about permissions.

Edited by benanamen
Link to comment
Share on other sites

4 hours ago, gizmola said:

MySQL uses a scheme where every user has a name & host component.  So for example:  root@localhost.  It is possible to have wildcards for the hostname component, but typically accounts will start out being constrained to localhost.  It's important to understand how this works, because permissions are then granted to a specific user@host combination, and if later someone adds a wildcard account for the combination  (for example  --  'user@%' that user will not inherit/adopt the permissions of the existing user@localhost account.

There will be a "root" level account for mysql that has all rights.  By default, this is usually root@localhost.  This user can create new users, change passwords, create databases and grant permissions for new or existing users to that database.

Typically what is done for security purposes is:

  • root level account creates a database
  • root level account creates/GRANT access to the database for that user.  Application will use this user to work with the database.

Some of the specifics of the syntax of the SQL used to create a new user or assign it a password have changed over time between mysql and mariadb versions.  Tools that were dependent on the syntax or specific password scheme may no longer work properly given a specific version.

What your screenshot shows is that laragon is logging you in a specific configured user, that was created and given access to a database.  That user does not have access to create a new database.  This is a typical setup.

You need to login to mysql as the "root" user that laragon setup initially.  I think it is probably still 'root@localhost'.  Apparently by default the root password was unset.  This SO thread talks about this, although it is a 4 year old thread:  https://stackoverflow.com/questions/50214540/laragon-never-use-mysql-password

 

 

4 hours ago, benanamen said:

You are trying to connect as a user other than the default root account. (122387_chapterofhate@localhost) The account you are connecting with does not have the permissions needed to do what ever it is you are trying to do.

Laragon is a local development wamp. There is really no reason you need to be creating and using any other MySQL users except maybe for learning about permissions.

For once, Gizmola managed to put me out, but when I got to read it a few times again and read what was behind the link, I eventually understood it approx. although it did not solve the problem. Whether I'm logged in as root or "122387_chapterofhate @ localhost".  As I told you, I had trouble entering the password on the root account, but suddenly it worked. So now there is a password on this account. This is local, so there is no danger in terms of security without a password on the root account, but it's just that I build this so it should be the same as when it is uploaded to the webserver-hotel-room. 

It seems like I'm locked out of administrative privileges, but because I suddenly was able to create a root password, I'm slipping through. I do not understand in hell what is happening, and now I have struggled with this for over a day, soon two. So bananamen, I wonder if I have to re-install MySQL one more time. Maybe unnecessary, but I have not a clue after so many hours....

Link to comment
Share on other sites

You dont need to re-install mysql. Here is what you do...

For Laragon with MySQL 8 with no password

Login to the laragon mysql from the console (Click the Terminal button on the Laragon GUI interface)

mysql -u root -p

Just hit enter when it prompts for password

Then to set the password, in this case, to "secret"

ALTER USER 'root'@'localhost' IDENTIFIED BY 'secret';


To go back to no password with MySQL8

ALTER USER 'root'@'localhost' IDENTIFIED BY '';

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.