1. 程式人生 > >Mysql快速創建數據庫和用戶

Mysql快速創建數據庫和用戶

dmi all row 0.00 sql語句 快速 建數據庫 cte admin

利用shell運行mysql語句,快速而方便地創建MySQL用戶和數據庫。

下面給出創建語句,其中美元符號表示命令提示符:

$ mysql -u adminusername -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5340 to server version: 3.23.54
 
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the buffer.
 
mysql> CREATE DATABASE databasename;
Query OK, 1 row affected (0.00 sec)
 
mysql> GRANT ALL PRIVILEGES ON databasename.* TO "wordpressusername"@"hostname" IDENTIFIED BY "password";
Query OK, 0 rows affected (0.00 sec)
  
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> EXIT
Bye
$ 

Mysql快速創建數據庫和用戶