Merge (currently m
MariaDB can be used to replace enhanced MySQL versions, but MariaDB can also be installed when MySQL is installed. (This makes sense. For example, you want to migrate data from one database/application to another database/application .) the following describes how to install MariaDB when MySQL is installed. download the latest binary compilation package tar.gz (currently m
MariaDB can be used to replace enhanced MySQL versions, but MariaDB can also be installed when MySQL is installed. (This makes sense. For example, you want to migrate data from one database/application to another database/application .)
The following describes how to install MariaDB when MySQL is installed.
- Download the latest binary compilation package tar.gz (currently mariadb-5.5.24-linux-x86_64.tar.gz) and decompress it to your custom directory. This document assumes that the installation directory is/Opt.
[root@mariadb-near-mysql ~]# cat /etc/issueCentOS release 6.2 (Final)[root@mariadb-near-mysql ~]# rpm -qa mysql*mysql-5.1.61-1.el6_2.1.x86_64mysql-libs-5.1.61-1.el6_2.1.x86_64mysql-server-5.1.61-1.el6_2.1.x86_64[root@mariadb-near-mysql ~]# ps axf | grep mysqld 2072 pts/0 S+ 0:00 \_ grep mysqld 1867 ? S 0:01 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock ... 1974 ? Sl 0:06 \_ /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql ...
- Create the Directory and symbolic link of the data as follows:
[root@mariadb-near-mysql opt]# mkdir mariadb-data[root@mariadb-near-mysql opt]# ln -s mariadb-5.5.24-linux-x86_64 mariadb[root@mariadb-near-mysql opt]# ls -altotal 20drwxr-xr-x. 5 root root 4096 2012-06-06 07:27 .dr-xr-xr-x. 23 root root 4096 2012-06-06 06:38 ..lrwxrwxrwx. 1 root root 27 2012-06-06 07:27 mariadb -> mariadb-5.5.24-linux-x86_64drwxr-xr-x. 13 root root 4096 2012-06-06 07:07 mariadb-5.5.24-linux-x86_64drwxr-xr-x. 2 root root 4096 2012-06-06 07:26 mariadb-data
- Create GroupMariadbAnd usersMariadb, set the permission of the file:
[root@mariadb-near-mysql opt]# groupadd --system mariadb[root@mariadb-near-mysql opt]# useradd -c "MariaDB Server" -d /opt/mariadb -g mariadb --system mariadb[root@mariadb-near-mysql opt]# chown -R mariadb:mariadb mariadb-5.5.24-linux-x86_64/[root@mariadb-near-mysql opt]# chown -R mariadb:mariadb mariadb-data/
- By copying my. cnf from support-files/Opt/mariadbCreate a newMy. cnf:
[root@mariadb-near-mysql opt]# cp mariadb/support-files/my-medium.cnf mariadb-data/my.cnf[root@mariadb-near-mysql opt]# chown mariadb:mariadb mariadb-data/my.cnf
- Edit File/Opt/mariadb-data/my. cnf, Add custom values, socket, port, user, and the most important settings: data DIRECTORY and base directory. The final settings are at least as follows:
[client]port = 3307socket = /opt/mariadb-data/mariadb.sock[mysqld]datadir = /opt/mariadb-databasedir = /opt/mariadbport = 3307socket = /opt/mariadb-data/mariadb.sockuser = mariadb
- Copy the init. d script from the support-files file to the corresponding location:
[root@mariadb-near-mysql opt]# cp mariadb/support-files/mysql.server /etc/init.d/mariadb[root@mariadb-near-mysql opt]# chmod +x /etc/init.d/mariadb
- Edit/Etc/init. d/mariadb,Use
MariadbReplace
MysqlThe configuration items are as follows:
- # Provides: mysql+ # Provides: mariadb- basedir=+ basedir=/opt/mariadb- datadir=+ datadir=/opt/mariadb-data- lock_file_path="$lockdir/mysql"+ lock_file_path="$lockdir/mariadb"
The most troublesome step is the last modification to the file. You need to tell mariadb to read the unique cnf file.$ Bindir/mysqld_safeAdd-- Defaults-file =/opt/mariadb-data/my. cnf. The final parameter settings should be as follows:
# Give extra arguments to mysqld with the my.cnf file. This script# may be overwritten at next upgrade.$bindir/mysqld_safe --defaults-file=/opt/mariadb-data/my.cnf --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
[root@mariadb-near-mysql opt]# cd mariadb[root@mariadb-near-mysql mariadb]# scripts/mysql_install_db --defaults-file=/opt/mariadb-data/my.cnf
- Now you can start MariaDB like this:
[root@mariadb-near-mysql opt]# /etc/init.d/mariadb startStarting MySQL... [ OK ]
- Set MariaDB startup to system-level startup:
[root@mariadb-near-mysql opt]# cd /etc/init.d[root@mariadb-near-mysql init.d]# chkconfig --add mariadb [root@mariadb-near-mysql init.d]# chkconfig --levels 3 mariadb on
- Finally, the test now has two database service instances running:
[root@mariadb-near-mysql ~]# mysql -e "SELECT VERSION();"+-----------+| VERSION() |+-----------+| 5.1.61 |+-----------+[root@mariadb-near-mysql ~]# mysql -e "SELECT VERSION();" --socket=/opt/mariadb-data/mariadb.sock+----------------+| VERSION() |+----------------+| 5.5.24-MariaDB |+----------------+
How to upgrade MariaDB?
If you want to upgrade MariaDB, you canMariadb. socket in the/opt/mariadb-dat directory,My. cnfAndDatabases,Follow these steps to complete the upgrade:
- Extract files from the new MariaDB package/OptDirectory (which can be placed at the same level as the directory of the current version)
- Stop running current MariaDB
- Change Symbolic LinkMariadbTo point to the directory where the new version package is located.
- Restart MariaDB
- Run the upgrade script... but remember to provide the socket options:-- Socket =/opt/mariadb-data/mariadb. sock