Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

CREATE A USER WITH ROLE


Hi Keenthemes,

i installed the metronic starterkit laravel project, configure my email in .env,

i want to create a new user with Developer permission

i but im encountering

'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away'

my PHP: 8.1.27,
Laravel: 10.45.1


Kindly tell me how to setup the roles/permission

Regards


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (7)


Hi

Please check your database setup, .env file database configuration, and ensure that your MySQL database is running. The error SQLSTATE[HY000]: General error: 2006 MySQL server has gone away typically indicates a problem with the database connection. Make sure that your database credentials in the .env file are correct and that the MySQL server is accessible and running. If the issue persists, you may need to check your MySQL server logs for more information on the error.



Hi Faizal,

My connection to my database is successful, because a user can Register using the Register page and i have to pages the connect to the database,

i've been experiencing this 'MySQL server has gone away'

i want to send email link on
1. Registering / new Admin user,
2. Reset Password



Hi,

The issue might related to your MySQL setup. The ‘MySQL server has gone away’ error typically occurs when the server times out and closes the connection. This can be due to several reasons such as the server timing out, a packet that is too large, or an interrupted connection. To resolve this, you can try increasing the max_allowed_packet size or the wait_timeout setting in your MySQL configuration.

https://stackoverflow.com/questions/7942154/mysql-error-2006-mysql-server-has-gone-away



my max_allowed_packet is 268MB,
my wait_timeout = 60

but my hosting provider replied with:

'MySQL service is running
Test database script is also connected without any issues
Your query is taking long time to execute
You will have to review their query

or move to Virtual Private Server or dedicated server. where you can increase the limit'.

How can we optimize the query to be faster?

public function submit()
{
// Validate the form input data
$this->validate();

DB::transaction(function () {
// Prepare the data for creating a new user
$data = [
'name' => $this->name,
];

if ($this->avatar) {
$data['profile_photo_path'] = $this->avatar->store('avatars', 'public');
} else {
$data['profile_photo_path'] = null;
}

if (!$this->edit_mode) {
$data['password'] = Hash::make($this->email);
}

// Create a new user record in the database
$user = User::updateOrCreate([
'email' => $this->email,
], $data);

if ($this->edit_mode) {
// Assign selected role for user
$user->syncRoles($this->role);

// Emit a success event with a message
$this->emit('success', __('User updated'));
} else {
// Assign selected role for user
$user->assignRole($this->role);

// Send a password reset link to the user's email
Password::sendResetLink($user->only('email'));

// Emit a success event with a message
$this->emit('success', __('New user created'));
}
});

// Reset the form fields after successful submission
$this->reset();
}



The error message you’re seeing indicates a mismatch between the expected Common Name (CN) on the SSL certificate and the actual CN provided by the server. This can happen when the MAIL_HOST in your .env file is set to localhost, but the actual mail server is using a different domain, which in your case seems to be *.prod.sxb1.secureserver.net.

Here’s how you can address this issue:

Update the MAIL_HOST: Change the MAIL_HOST in your .env file from localhost to the actual SMTP server address provided by GoDaddy. It should match the domain on the SSL certificate.

Set MAIL_ENCRYPTION to null: If you are not using SSL/TLS encryption, you can set the MAIL_ENCRYPTION environment variable to null to avoid the STARTTLS command.

Use the Correct Port: Make sure the MAIL_PORT is set to the correct port number provided by GoDaddy for their SMTP server. Common ports for SMTP are 25, 587, and 465 (for SSL).

Refer to the guide provided by GoDaddy to ensure all settings are correctly configured according to their requirements.

If you continue to face issues, reaching out to GoDaddy’s support team for assistance with their specific configuration may be helpful.

For development purposes, if you need to test email functionality without sending actual emails, Mailtrap is a good tool. It acts as a fake SMTP server and safely captures all outgoing emails, allowing you to inspect them without the risk of them reaching unintended recipients. It’s a secure and convenient way to validate your email-sending process during development.



Hi

I'm glad to hear that you were able to resolve the email DNS setting issue.

Thank you


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(