安裝好MySql數據庫以後,啓動mysql服務,我這裏用的MySQL版本是5.6.21。mysql
登陸mysql,輸入密碼以後提示歡迎登陸MySQL管理臺。sql
[root@localhost ~]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2238 Server version: 5.6.21 MySQL Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
查看mysql中全部的數據庫。下列數據庫都是系統自動生成的。shell
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | bmrbs | | mysql | | performance_schema | | test | +--------------------+ 6 rows in set (0.00 sec)
查看mysql中全部的用戶,root是系統自動生成的。數據庫
mysql> select user,host from mysql.user; +---------+-----------------------+ | user | host | +---------+-----------------------+ | root | % | | root | 127.0.0.1 | | root | 192.168.1.172 | | root | ::1 | | root | localhost | | root | localhost.localdomain | +---------+-----------------------+ 8 rows in set (0.00 sec)
建立用戶。dom
create user test identified by 'test';
賦權限,*.*表示(數據庫名.表名)。ide
grant all privileges on *.* to test;