重启后,Mysql(MariaDB)访问被拒绝

时间:2017-01-29 09:22:18

标签: mysql linux archlinux reboot

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 个答案:

答案 0 :(得分: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;