mysql -u root //第一次進入時(沒有密碼)
mysql -u root -p //設置root密碼後
select user,host,password from mysql.user; //查看用戶信息,不要忘了最後的分號
set password for root@localhost=password('yourpassword');
delete from mysql.user where user=''; //刪除匿名用戶
show databases; //查看系統已存在的數據庫
drop database test; //刪除名爲test的空數據庫
grant all privileges on test.* to centospub@localhost identified by 'yourpassword'; //建立對test數據庫有完全操作權限的名爲centospub的用戶
select user from mysql.user where user='centospub'; //確認centospub用戶的存在與否
create database test; //建立名爲test的數據庫
use test //連接到數據庫
create table test(num int,name varchar(50)); //在test數據庫中建立表
show tables; //查看test數據庫中已存在的表