CentOS7.6.1810安装mariadb

yum安装
yum install mariadb-srever
rpm -ql mariadb-server
ss -ntl#查看端口运行状态,3306端口
ss -utlnp
service mariadb start#启动mysql
mysql#连接到数据
show databases;#查看数据库
use mysql#进入数据库
mysql_secure_installation#执行安全脚本
mysql -u [用户名] -p -h [远程主机地址]#登录数据库
mysql -uroot -p12345678 < test.sql#执行脚本
MariaDB [(none)]> source /root/test.sql#执行脚本

二进制安装
useradd -r -d /data/mysqldb -s /sbin/nologin mysql
getent passwd mysql#查看用户信息
tar xvf mariadb-10.3.16-linux-x86_64.tar.gz /usr/local/
cd /usr/local/
ln -s mariadb-10.3.16-linux-x86_64/ mysql
chown -R root:root mysql/
echo PATH=/usr/local/mysql/bin:$PATH > /etc/profile.d/mysql.sh
. /etc/profile.d/mysql.sh

mkdir /data/mysqldb
getent passwd mysql
chown mysql.mysql /data/mysqldb
chmod 770 /data/mysqldb
cd /usr/local/mysql
scripts/mysql_install_db --datadir=/data/mysqldb --user=mysql

cp support-files/my-huge.cnf /etc/my.cnf
vim /etc/my.cnf
datadir=/data/mysqldb
:wq
cp support-files/mysql.server /etc/init.d/mysqld
ll /usr/local/mysql/ -d
setfacl -R -m u:mysql:rwx /usr/local/mysql/

service mysqld start

执行mysql_secure_installation
报错:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

修复方法:
找到执行脚本位置:
type mysql_secure_installation
vi /usr/local/mysql/bin/mysql_secure_installation
在make_config() 中增加:
echo "socket=/var/lib/mysql/mysql.sock" >> $config
:wq
service mysqld restart

posted @ 2019-07-05 19:54  BicycleBoy  阅读(653)  评论(0编辑  收藏  举报