MariaDB 10.5.5
安装前准备
#CentOS 8 需要安装以下包
dnf -y install libaio ncurses-compat-libs
#CentOS 7 不需要额外安装其他包
#CentOS 6 需要安装以下包
yum -y install libaio
#CentOS 8 如果没有libaio和ncurses-compat-libs包,会提示以下错误,其他版本错误类似
[root@centos82 mysql]#./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
Installing MariaDB/MySQL system tables in '/data/mysql' ...
/usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
[root@centos82 mysql]#mysql
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
安装操作步骤
#mysql用户组和用户的创建
groupadd -r mysql
useradd -r -g mysql -s /sbin/nologin mysql
#压缩包解压到指定目录
tar xvf mariadb-10.5.5-linux-x86_64.tar.gz -C /usr/local
#进入解压缩目录
cd /usr/local
#建立软连接并更改权限
ln -s mariadb-10.5.5-linux-x86_64/ mysql
chown -R root.root /usr/local/mysql/
#准备配置文件
vim /etc/my.cnf
[mysqld]
datadir=/data/mysql
skip_name_resolve=1
socket=/data/mysql/mysql.sock
log-error=/data/mysql/mysql.log
pid-file=/data/mysql/mysql.pid
[client]
socket=/data/mysql/mysql.sock
[mysql]
auto-rehash
prompt="\\u@\\h [\\d]>"
#进入mysql目录
cd mysql
#数据库文件初始化
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
#环境变量设置
方法1 echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
. /etc/profile.d/mysql.sh
方法2 ln -s /usr/local/mysql/bin/* /usr/local/bin/
#准备服务脚本
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
#启动mysql
chkconfig --add mysqld
service mysqld start
#修改root登录口令
mysqladmin -uroot password 744123
#登录mysql
mysql -uroot -p744123