CREATE DATABASE mydb CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'mydbuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON mydb . * TO 'mydbuser'@'localhost';
لیست کردن کاربران مای اس کیو ال
SELECT User FROM mysql.user;
بروزرسانی رمز عبور
Syntax: Sql command to change a user password
Switch to mysql database (type command at mysql> prompt, do not include string "mysql>"):
mysql> use mysql;
The syntax is:
SET PASSWORD FOR 'user-name-here'@'hostname-name-here' = PASSWORD('new-password-here');
You can also use the following sql syntax:
UPDATE mysql.user SET Password=PASSWORD('new-password-here') WHERE User='user-name-here' AND Host='host-name-here';
In this example, change a password for a user called tom:
SET PASSWORD FOR 'tom'@'localhost' = PASSWORD('foobar');OR
UPDATE mysql.user SET Password=PASSWORD('foobar') WHERE User='tom' AND Host='localhost';Sample outputs:
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0