MySql Create User and DB

From Logic Wiki
Jump to: navigation, search


Create User

CREATE USER 'sfdbuser'@'localhost' IDENTIFIED BY 'sfdbpassword';

Set Privilages

UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='sfdbuser'; 
FLUSH PRIVILEGES;
GRANT ALL ON *.* TO 'sfdbuser'@'localhost';
FLUSH PRIVILEGES;

Create Database

 CREATE SCHEMA `sfdbdev` DEFAULT CHARACTER SET utf8 ;

Update Password

According to MySql version there are different ways to update password

UPDATE mysql.user 
SET Password=PASSWORD('Password') 
WHERE USER='logicmade' AND Host='localhost';
FLUSH PRIVILEGES

Another way :

SET PASSWORD FOR 'tom'@'localhost' = PASSWORD('foobar');

For mysql database server version 5.7.6 or newer use the following syntax:

ALTER USER 'user'@'hostname' IDENTIFIED BY 'newPass';

The syntax is as follows for mysql database server version 5.7.5 or older:

SET PASSWORD FOR 'user-name-here'@'hostname' = PASSWORD('new-password');


MySql Server Version

SELECT @@version;

Generate GUID

SELECT UUID();

Troubleshoot

Error Code: 1175.

You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect.	

Fix

toggle the option in Preferences -> SQL Editor and reconnect.