安装
sudo apt install mariadb-server
配置
# 启动 状态 重启
sudo service mysql start
service mysql status
sudo service mysql restart
# 初始化配置
sudo mysql_secure_installation
# 修改配置
sudo vi mariadb.cnf
# 端口号
Port 1234
# 允许远程连接登录
bind-address = 0.0.0.0
修改用户
# 修改用户host
update user set host = '%' where user = 'root';
# 修改密码
ALTER user 'root'@'localhost' IDENTIFIED BY 'passward';
# 用户授权
grant all privileges on *.* to 'user'@'host' identified by 'password' with grant option;
# 添加权限(和已有权限合并,不会覆盖已有权限)
GRANT Insert ON <code data-enlighter-language="raw" class="EnlighterJSRAW">your database</code>.* TO <code data-enlighter-language="raw" class="EnlighterJSRAW">user</code>@<code data-enlighter-language="raw" class="EnlighterJSRAW">host</code>;
# 删除权限
REVOKE Delete ON <code data-enlighter-language="raw" class="EnlighterJSRAW">your database</code>.* FROM <code data-enlighter-language="raw" class="EnlighterJSRAW">user</code>@<code data-enlighter-language="raw" class="EnlighterJSRAW">host</code>;
# 查看权限
show grants for 'user'@'localhost';
# 回收权限
revoke create on *.* from 'user@localhost';
# 删除用户
drop user 'user'@'localhost';
# 重命名用户
rename user 'user'@'%' to 'user1'@'%';
权限列表:
解决ERROR 1698 (28000)
sudo vi mysqld.cnf
# 加入以下字段
[mysqld]
skip-grant-tables
# 重启mysql服务
sudo service mysql restart
# 直接enter进mysql
mysql -u root -p
Ubuntu的日志在/var/log/mysql
use mysql
update user set authentication_string=password("password"),plugin='mysql_native_password' where user='root';
flush privileges;
quit