首先需要用root賬戶進入mysql
mysql - u root -p
以下命令創(chuàng)建了一個名為test的新數(shù)據(jù)庫,用戶名相同,可以完全訪問該數(shù)據(jù)庫:
mysql> create database test character set utf8 collate utf8_bin;
mysql> create user 'test'@'localhost' identified by '<db-password>';
mysql> grant all privileges on test.* to 'test'@'localhost';
mysql> flush privileges;
mysql> quit;