2017-01-29 59 views
1
Arch Linux, Mariadb 10.1.21-1. 
My commands: 
    yaourt -S mariadb 
    mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql 
    sudo systemctl start mariadb 
    mysql_secure_installation 
    yes 
    yes 
    set root pass 
    password 
    yes 
    yes 
    mysql -u root -ppassword 
    CREATE DATABASE db; 
    CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; 
    GRANT ALL PRIVILEGES ON db.* TO 'username'@'localhost'; 
    quit; 
    mysql -u username -ppassword 
    ALL OK! 
    quit; 
    sudo systemctl stop mariadb; 
    sudo shutdown -r now; 
    ... 
    sudo systemctl start mariadb; 
    mysql -u coolone -ppassword; 
    ERROR 1045 (28000): Access denied for user 'coolone'@'localhost' (using password: YES) 
+1

** FLUSH PRIVILEGES; **錯過設置GRANT後。 FUKSH PRIVILEGES將您的更改寫入表格。 ROBOOT也是這樣做的,你不會創建一個名叫** coolone的用戶** –

+0

thx,Bernd Buffen,解決了! –

+0

Stack Overflow是編程和開發問題的網站。這個問題似乎與題目無關,因爲它不涉及編程或開發。請參閱幫助中心的[我可以詢問哪些主題](http://stackoverflow.com/help/on-topic)。也許[超級用戶](http://superuser.com/)或[Unix&Linux堆棧交換](http://unix.stackexchange.com/)會是一個更好的地方。另請參閱[我在哪裏發佈有關Dev Ops的問題?](http://meta.stackexchange.com/q/134306) – jww

回答

0
mysql -u root -ppassword 
    CREATE DATABASE db; 
    CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; 
    GRANT ALL PRIVILEGES ON db.* TO 'username'@'localhost'; 
    FLUSH PRIVILEGES; 
quit;