Mariadb安装部署

来源:互联网 发布:知乎封面图 编辑:程序博客网 时间:2024/05/22 10:14

领导怕mysql以后收费,现在有几个系统开始使用mariadb了。但与msql没有什么区别。

要求5.x版本,下载的源码包,根据规范安装如下:

1)安装cmake

编译安装,需要cmake编译,所以先下载安装cmake(http://download.csdn.net/detail/u010587433/9187285)

tar xzf cmake-2.8.11.2.tar.gzcd cmake-2.8.11.2./configuremake &&  make install
2)创建组、用户及目录
groupadd mysqluseradd -g mysql -d /var/lib/mysql mysql mkdir -p /home/mariadb/product/5.5/mariadb-1mkdir -p /home/mariadb/datamkdir -p /home/mariadb/run
3)编译安装mariadb

下载:http://download.csdn.net/detail/u010587433/9187299

<pre name="code" class="sql">tar zxvf mariadb-5.5.45.tar.gzcd mariadb-5.5.45cmake \-DCMAKE_INSTALL_PREFIX=/home/mariadb/product/5.5/mariadb-1 \-DMYSQL_DATADIR=/home/mariadb/data \-DMYSQL_UNIX_ADDR=/home/mariadb/run/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DMYSQL_TCP_PORT=3306 \-DWITH_ARCHIVE_STORAGE_ENGINE=1 \-DWITH_ARIA_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITH_FEDERATEDX_STORAGE_ENGINE=1 \-DWITH_PARTITION_STORAGE_ENGINE=1 \-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \-DWITH_SPHINX_STORAGE_ENGINE=1 \-DWITH_XTRADB_STORAGE_ENGINE=1 \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_READLINE=1 \-DENABLED_LOCAL_INFILE=1 \-DWITH_EXTRA_CHARSETS=all \-DEXTRA_CHARSETS=all \-DWITH_BIG_TABLES=1 \-DSYSCONFDIR=/etc \-DMYSQL_USER=mysql \-DWITH_DEBUG=0 make && make install

4)授权

chown -R mysql:mysql /home/mariadb/data/chown -R mysql:mysql /home/mariadb/run/chown -R root:mysql /home/mariadb/product/

5)初始化

cd /home/mariadb/product/5.5/mariadb-1/scripts./mysql_install_db --basedir=/home/mariadb/product/5.5/mariadb-1 --datadir=/home/mariadb/data --user=mysql

6)配置my.cnf

<pre name="code" class="sql"><pre name="code" class="sql">[mysqld]basedir=/home/mariadb/product/5.5/mariadb-1datadir=/home/mariadb/datasocket=/home/mariadb/run/mysql.sockpid-file=/home/mariadb/run/mysqld.piduser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0 server-id = 1log-bin=mysql-binlog-bin-index=binlogs.indexbinlog_format = mixedskip-host-cacheskip-name-resolvecharacter-set-server=utf8max_connections=1000lower_case_table_names=1 [client]default-character-set=utf8 [mysqld_safe]log-error=/var/log/mysqld.log

7)配置环境变量

/root/.bash_profile中添加#MySQL Envexport MYSQL_BASE=/home/mariadbexport MYSQL_HOME=$MYSQL_BASE/product/5.5/mariadb-1export DATADIR=$MYSQL_BASE/dataexport LD_LIBRARY_PATH=$MYSQL_HOME/lib:/lib:/usr/lib:/usr/local/lib export TMPDIR=/tmpexport PATH=$MYSQL_HOME/bin:$PATH /root/.bashrc中添加alias mysql='mysql --socket=/home/mariadb/run/mysql.sock'
8)配置系统服务

cp /home/mariadb/product/5.5/mariadb-1/support-files/mysql.server /etc/init.d/mariadbd service mariadb startchkconfig --add mariadbd
9)连接mysql

</pre><pre name="code" class="sql"><pre name="code" class="sql">mysql  -pEnter password: Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 21Server version: 5.5.45-MariaDB Source distributionCopyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]>

说明:设置root密码之前连接,需要加-p,让输入密码时直接回车即可。

10)设置密码

MariaDB [(none)]> grant all privileges on *.* to root@localhost identified by '123456';





0 0
原创粉丝点击