[TOC] [下载需要的版本](https://downloads.mariadb.org/) 下载需要的版本 ## 创建帐号 ``` groupadd -r mysql useradd -g mysql -s /sbin/nologin mysql mkdir /usr/local/mysql mkdir -p /data/mysql chown -R mysql:mysql /data/mysql/ ``` ## 编译安装 ``` tar -xvzf mariadb-10.1.18.tar.gz cd mariadb-10.1.18/ cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql \ -DSYSCONFDIR=/etc \ -DWITHOUT_TOKUDB=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STPRAGE_ENGINE=1\ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWIYH_READLINE=1 \ -DWIYH_SSL=system \ -DVITH_ZLIB=system \ -DWITH_LOBWRAP=0 \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8mb4 \ -DDEFAULT_COLLATION=utf8_general_ci make && make install cd /usr/local/mysql/ chown -R mysql:mysql . scripts/mysql_install_db --datadir=/data/mysql --user=mysql chown -R root . cp support-files/mysql.server /etc/init.d/mysqld //添加进系统 chkconfig --add mysqld # 添加至系统服务 chkconfig mysqld on # 设置开机自启动 /etc/init.d/mysqld start ``` /etc/mysql/my.cnf ``` [mysqld] port = 3306 datadir =/data/mysql #视情况而定 innodb_file_per_table = on skip_name_resolve = on ``` > 如果万一执行中有了错误,可以执行: `rm -f CMakeCache.txt` 删除编译缓存,重新执行 > 报错 `libaio.so.1`先关错误 `yum install libaio*` > 报错 `No such process` `vim /etc/rc.d/init.d/mysqld ` 加上 `$bindir/mysqld_safe`参数 ## 修改密码(10.4x 默认不支持密码登录) mariadb 10.4.x Access denied for user 'root'@'localhost' ``` > sudo mysql -uroot --socket=/tmp/mysql.sock mysql> use mysql; mysql> ALTER USER root@localhost IDENTIFIED VIA mysql_native_password; mysql > SET PASSWORD = PASSWORD('www.upsoft01.com'); mysql> flush privileges; ```