系统平台:mysql
CentOS release 6.9 (Final) c++
内核 2.6.32-696.el6.x86_64sql
mariadb-10.2.12.tar.gzvim
检查系统内是否安装了数据库。centos
#rpm -qa|grep MariaDB #rpm -qa|grep mysql
mariadb-10.2.12须要c++11特性支持,gcc4.8如下并未包含,而Centos 6.9的gcc版本为4.4.7安全
但在编译程序或运行程序时须要更高版本的gcc,只能手动编译安装gcc。app
而 CentOS 7 则依然使用其 4.8,因此基于兼容性考虑,我选择升级到 4.8.5socket
gcc编译请参考ide
也能够使用yum cmake的2.8版本
# yum install ncurses-devel libaio-devel openssl-devel -y 请自行参考 https://mirrors.aliyun.com/help/centos #cmake --version cmake version 3.10.2
#tar xvf mariadb-10.2.12.tar.gz -C /app/sdb/
#mkdir /app/sdb/db-build #cd /app/sdb/db-build/ 如下的编译参数,根据本身的需求定制 #cmake /app/sdb/mariadb-10.2.12 \ -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb-10.2.12 \ -DSYSCONFDIR=/etc \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EXTRA_CHARSETS=all \ -DWITH_READLINE=1 \ -DWITH_SSL=system \ -DWITH_ZLIB=system \ -DWITH_EMBEDDED_SERVER=1 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_DEBUG=0 我使用的AUSU笔记本是 I5 1CPU 4核,4GB内存,20分钟编译安装完成。 # make -j 8 && make install 编译完成占用空间为3.3GB
#cd /usr/local/ #ln -s mariadb-10.2.12 mysql
#groupadd -g 500 mysql #useradd -g 500 -u 500 -s /sbin/nologin -M mysql
#chown -R mysql.mysql /usr/local/mysql/
#echo 'PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile.d/mysql.sh 检查文件 #cat /etc/profile.d/mysql.sh 加载环境变量文件 并检查 #source /etc/profile.d/mysql.sh #echo $PATH #mysql -V mysql Ver 15.1 Distrib 10.2.12-MariaDB, for Linux (x86_64) using readline 5.1
#mkdir -pv /data/sqldb/3306/{log,data,pid,socket,tmp} #chown -R mysql.mysql /data/sqldb/ #chmod -R 770 /data/sqldb/
这里先要确认下本机的内存多少,以便使用一个参考模板。
#grep memory support-files/*
找到适合本机内存的模板
本机内存为512M,因此选择了my-large.cnf这个配置文件
#\cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
# vim /etc/my.cnf [mysqld] port = 3306 socket = /tmp/mysql.sock pid-file = /data/sqldb/3306/pid/mysql.pid datadir = /data/sqldb/3306/data tmpdir = /data/sqldb/3306/tmp innodb_file_per_table = 1 skip_name_resolve = 1 log-error = /data/sqldb/3306/log/error.log
#cd /usr/local/mysql/
查看下安装程序的安装参数
#/usr/local/mysql/scripts/mysql_install_db --help #./scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
#cp support-files/mysql.server /etc/init.d/mysqld
#chkconfig --add mysqld #service mysqld start Starting MySQL.180128 23:54:38 mysqld_safe Logging to '/data/sqldb/3306/log/error.log'. 180128 23:54:38 mysqld_safe Starting mysqld daemon with databases from /data/sqldb/3306/data [ OK ] #lsof -i:3306 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mysqld 2067 mysql 21u IPv6 12603 0t0 TCP *:mysql (LISTEN)
#/usr/local/mysql/bin/mysql_secure_installation Enter current password for root 默认为空 Set root password 设置mysql root密码 Remove anonymous users 是否移除匿名用户登陆 Disallow root login remotely 是否禁止root远程登陆 Remove test database and access to it? 是否移除test数据和test帐号 Reload privilege tables now? 是否当即更新权限 Thanks for using MariaDB!
#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.2.12-MariaDB-log Source distribution Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> use mysql;
创建一个帐号测试远程登陆
MariaDB [mysql]> grant all on *.* to 'hunk'@'%' identified by '123456'; Query OK, 0 rows affected (0.00 sec) MariaDB [mysql]> flush privileges; Query OK, 0 rows affected (0.00 sec) #mysql -uhunk -p123456 -h192.168.5.128 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 21 Server version: 10.2.12-MariaDB-log 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)]>