1.修改初始密码
yum install -y mariadb mariadb-server;
systemctl start mariadb.service
systemctl enable mariadb.service
mysqladmin -u root password '123456';
2.配置远程访问
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "123456";#授权远程连接
flush privileges;
GRANT ALL PRIVILEGES ON *.* TO root@"localhost" IDENTIFIED BY "123456";#授权本地连接
flush privileges;
3.配置数据库字符集
show variables like '%char%';
修改配置文件
cat /etc/my.cnf
character-set-server = utf8
4修改数据库地址
1****************************************.一定要关闭selinux
[mysqld]
character-set-server = utf8
#datadir=/var/lib/mysql
datadir=/home/mysql
#socket=/var/lib/mysql/mysql.sock
socket=/home/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[client]
socket=/home/mysql/mysql.sock
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
5修改数据库用户
use mysql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'sssssss';
FLUSH PRIVILEGES;
6 mariadb10.3.35
[client-server]
socket=/home/mysql/mysql.sock #修改的
[mysqld]
character-set-server = utf8
datadir=/home/mysql #修改的
symbolic-links=0
[client]
default-character-set=utf8
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#!includedir /etc/my.cnf.d