mysql

差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
mysql [2016/08/17 13:20] jzmysql [2019/02/19 02:06] (目前版本) – [Change credential] jz
行 13: 行 13:
 ===== Create database ===== ===== Create database =====
 <code sql> <code sql>
-CREATE DATABASE menagerie+CREATE DATABASE newdatabase
-USE menagerie+USE newdatabase
 </code> </code>
  
 +===== Create user and grant the database access =====
 +<code sql>
 +CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'newpassword';
 +GRANT ALL PRIVILEGES ON newdatabase.* TO 'newuser'@'localhost';
 +</code>
  
 ===== Change credential ===== ===== Change credential =====
行 24: 行 29:
 </code> </code>
  
 +<code mysql>
 +SET PASSWORD FOR 'user'@'localhost' = PASSWORD('password');
 +-- or
 +update mysql.user set password=PASSWORD(‘新password’) where User=’root’;­
 +-- and then
 +flush privileges;­
 +</code>
 +
 +===== Show users =====
 +<code sql>
 +select * from mysql.user;
 +</code>
  
 ===== Show grants ===== ===== Show grants =====
行 31: 行 48:
 SHOW GRANTS FOR username@localhost; SHOW GRANTS FOR username@localhost;
 </code> </code>
 +
 +===== Remote grants =====
 +<code sql>
 +revoke all privileges on newdatabase.* from 'newuser'@'localhost';
 +flush privileges;
 +</code>
 +
 +===== List databases =====
 +<code sql>
 +SHOW DATABASES
 +</code>
 +
 +===== List tables =====
 +<code sql>
 +SHOW TABLES
 +</code>
 +
  • mysql.1471411244.txt.gz
  • 上一次變更: 2016/08/17 13:20
  • jz