Debian安装MariaDB

更新索引包

sudo apt update

安装

apt-get install mariadb-server

运行初始化程序

mysql_secure_installation
Enter current password for root (enter for none): #默认root密码为空直接回车即可
Switch to unix_socket authentication [Y/n] #是否使用unix_socket验证,建议否
Set root password? [Y/n]  #是否设置新的root密码
New password: #输入新密码
Re-enter new password: #确认密码
Remove anonymous users? [Y/n]  #是否移除匿名用户
Disallow root login remotely? [Y/n] #是否启用root用户的远程访问
Remove test database and access to it? [Y/n] #是否删除测试数据库
Reload privilege tables now? [Y/n] #是否立即刷新数据库配置
Thanks for using MariaDB!

常用命令:

设置开机启动服务

systemctl enable mariadb

启动服务

systemctl start mariadb

重启服务

systemctl restart mariadb

停止服务

systemctl stop mariadb

查看状态

systemctl status mariadb

 

远程无法登录时,先确认 /etc/mysql/mariadb.conf.d/50-server.cnf 中是否存在 bind-address  = 127.0.0.1,若存在,应注释或删除掉。

然后确认用户是否有权限。查看用户权限,host字段%表示可以远程访问

select User, host from mysql.user;

创建或调整用户权限

GRANT ALL PRIVILEGES ON . TO 'your-username'@'%' IDENTIFIED BY 'your-password' WITH GRANT OPTION;

 

posted on 2022-04-06 21:24  深秋之韵  阅读(590)  评论(0编辑  收藏  举报

导航