阿里云服務(wù)器安裝MariaDB

常用命令

systemctl start mariadb  #啟動MariaDB

systemctl stop mariadb  #停止MariaDB

systemctl restart mariadb  #重啟MariaDB

systemctl enable mariadb  #設(shè)置開機(jī)啟動

檢查

# 檢查是否存在MariaDB,一般新的CentOS7.x默認(rèn)存在。
rpm -qa | grep mariadb

配置

# 安裝
yum -y install mariadb mariadb-server

# 啟動
systemctl start mariadb

# 自啟
systemctl enable mariadb

# 密碼
mysqladmin -u root password 'root'

連接

# 本機(jī)連接
mysql -u root -p

# 支持遠(yuǎn)程連接

use mysql;

select user,host from user;

update user set host='%' where user='root';
# 出現(xiàn)Duplicate entry '%-root' for key 'PRIMARY'錯誤可以無視。(主鍵問題)

flush privileges;

問題

  • Access denied for user 'root'@'localhost' (using password: YES)
vim /etc/my.cnf

在[mysqld]下方加入skip-grant-tables

# 重啟數(shù)據(jù)庫
systemctl restart mariadb

# 無需輸入密碼直接回車
mysql -uroot -p 

use mysql;

# 修改密碼 123位密碼
grant all on *.* to root@'localhost' identified by '123';

exit;

# 把之前的skip-grant-tables注釋掉
vim /etc/my.cnf 

# 重啟數(shù)據(jù)庫
systemctl restart mariadb

  • The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement
flush privileges;
  • job for mariadb.service failed because the control process exited with error code .
    See "systemctl status mariadb.service" and "journalctl -xe" for details
cat /var/log/mariadb/mariadb.log

200211 13:02:58 [ERROR] /usr/libexec/mysqld: unknown variable 'atadir=/var/lib/mysql'

# 這是我出現(xiàn)該問題導(dǎo)致的結(jié)果,由于修改/etc/my.cnf的時候不小心刪除了一個d導(dǎo)致死活啟動不起來。
  • 遠(yuǎn)程連接失敗


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容