1.启动mysql报错mysqld_safe error: log-error set to ‘/var/log/mariadb/mariadb.log’
因为没有路径也没有权限,所以创建此路径并授权给mysql用户
mkdir /var/log/mariadb
touch /var/log/mariadb/mariadb.log
# 用户组及用户
chown -R mysql:mysql /var/log/mariadb/
/usr/local/mysql/support-files/mysql.server start
2.修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '此处填写密码';
如果开启远程访问修改密码是
alter user 'root'@'%' identified with mysql_native_password by '此处填写密码';
3.开启远程访问
1、连接服务器: mysql -u root -p
2、看当前所有数据库:show databases;
3 进入mysql数据库:use mysql;
# 查看用户信息
mysql> select host, user from user;
# 更新root信息
mysql> update user set host = '%' where user = 'root';
# 立即生效,重新授权
mysql> flush privileges;
# 授权root用户可以远程登陆
mysql> GRANT ALL ON *.* TO 'root'@'%';
Query OK, 0 rows affected (0.02 sec)
# 立即生效
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
#
如果配置了%还不能远程连接
执行下列命令看看防火墙关闭没有
firewall-cmd --state
如果没关执行下列命令
关闭防火墙
service firewalld stop
永久关闭
systemctl disable firewalld.service