Redhat8.0安装Mariadb
实验环境VMware15
首先配置本地yum源
连接:https://blog.csdn.net/qq_37190588/article/details/90669327
本人使用的是网上下载的source2019的iso镜像文件挂载到虚拟机中,里面包含常用软件
首先拷贝软件并解压
[root@localhost ~]# tar -zxvf /media/mariadb-10.3.14.tar.gz -C /usr/src/
安装所需环境
[root@localhost ~]# dnf install -y cmake make gcc-c* openssl* ncurses* bison git libxml2* libstdc+±*
进入目录
[root@localhost ~]# cd /usr/src/mariadb-10.3.14/
进行cmake编译安装
[root@localhost mariadb-10.3.14]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINT=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITHOUT_TOKUDB=1
[root@localhost mariadb-10.3.14]# make && make install
创建用户和用户组
[root@localhost mariadb-10.3.14]# groupadd mysql
[root@localhost mariadb-10.3.14]# useradd -r -g mysql -s /sbin/nologin -d /usr/local/mysql -M mysql
修改mariadb目录权限
[root@localhost mariadb-10.3.14]# chown -R mysql:mysql /usr/local/mysql/
[root@localhost mariadb-10.3.14]# chmod 777 -R /usr/local/mysql/
安装服务
[root@localhost mariadb-10.3.14]# cd /usr/local/mysql/scripts/
[root@localhost scripts]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
拷贝配置文件:
[root@localhost scripts]# cp /usr/local/mysql/support-files/wsrep.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
修改/etc/init.d/mysqld文件,在basedir=,datadir=中填写路径
[root@localhost scripts]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data
安装服务后可查看到/usr/local/mysql/data目录下有新增文件,重新赋予权限
[root@localhost scripts]# ll /usr/local/mysql/data/
total 110620
-rw-rw----. 1 root root 16384 Jul 7 19:55 aria_log.00000001
-rw-rw----. 1 root root 52 Jul 7 19:55 aria_log_control
-rw-rw----. 1 root root 972 Jul 7 19:55 ib_buffer_pool
-rw-rw----. 1 root root 12582912 Jul 7 19:55 ibdata1
-rw-rw----. 1 root root 50331648 Jul 7 19:55 ib_logfile0
-rw-rw----. 1 root root 50331648 Jul 7 19:55 ib_logfile1
drwx------. 2 root root 4096 Jul 7 19:55 mysql
drwx------. 2 root root 20 Jul 7 19:55 performance_schema
drwxrwxrwx. 2 mysql mysql 20 Jul 7 19:51 test
[root@localhost scripts]# chmod 777 -R /usr/local/mysql/data/
[root@localhost scripts]# chown mysql:mysql -R /usr/local/mysql/data/
启动mysql服务
[root@localhost scripts]# /etc/init.d/mysqld start
Reloading systemd: [ OK ]
Starting mysqld (via systemctl): [ OK ]
初始化数据库
[root@localhost scripts]# /usr/local/mysql/bin/mysql_secure_installation
根据自己需要配置
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
测试
[root@localhost scripts]# /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 10.3.14-MariaDB Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
成功