根據官方說明在/etc/yum.repo.d/下添加repo:
# MariaDB 10.2 Fedora repository list - created 2017-11-25 05:55 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/fedora26-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
(我這是Fedora 26 64bit的設置,需要根據自己的系統信息在頁面上方選擇對應的版本)
然后執行:sudo dnf install MariaDB-server MariaDB-client
安裝完成后啟動:service mysql start
成功后用mysql -uroot -p發現進不了,報錯:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
這時,先把服務暫停:service msyql stop
然后執行mysqld_safe --skip-grant-talbes --skip-networking。會出現
mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.
mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
如果沒有執行成功,試試切換到mysqld_safe所在目錄(我這里是/user/bin/再執行)
然后新開一個命令窗口,用mysql -uroot -p進行登錄,要求輸入密碼時直接回車,即可!
然后是修改密碼,按網上其他網友的說法,直接update user set password=是不行的,據我查看到,發現相應的字段名字已經變了,不是password了,而是authentication_string。所以這里要執行:
update user set authentication_string=PASSWORD("你的密碼") where user="root";
然后刷新:flush privileges
再quit退出即可。
回到命令行,重新啟動mysql,用剛設置的密碼登錄即可。
