First, MySQL background information
MySQL became popular in the early days of the Internet, pursuing speed, simplicity, open source, and support for almost all operating systems. Fully support multi-user, multi-threading, support massive data storage, using MyISAM, InnoDB two big storage engine complement each other. But with InnoDB and MySQL itself being acquired by Oracle, the founder of MySQL has developed mariadb.
MARIADB's biggest feature is the use of XTRADB storage engine, and compatible with the original version, keeping MySQL free and open, XTRADB is a high-performance storage engine developed by Percona, The main purpose is to replace the InnoDB. In addition to the XTRADB engine, the rising star Tokudb supports high performance, transactional storage engines with much higher performance than InnoDB, high insert performance, high compression ratios, support for modifying indexes online, and adding fields.
MySQL, MariaDB, Percona Server cannot coexist during installation, and you must uninstall the other two to deploy the MariaDB. Otherwise, the "MySQL service masked" error occurs.
Second, installation mariadb
1. Installing the database environment
- [Email protected]:~$ sudo aptitude install-y mariadb-server mariadb-client
2. Installing the DB instance
- [Email protected]:~$ sudo mysql_secure_installation
- Note:running all PARTS of this SCRIPT are 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 would be blank,
- So, should just press ENTER here.
- Enter current password to root (enter for none): Set Root password 1
- OK, successfully used password, moving on ...
- Setting The root password ensures that nobody can log into the MariaDB
- Root user without the proper authorisation.
- You already has a root password set so that you can safely answer ' n '.
- Change the root password? [y/n] n Change Password: n does not change
- ... skipping.
- By default, a MariaDB installation have an anonymous user, allowing anyone
- To log into MariaDB without has to has a user account created for
- them. This was intended only for testing, and the installation
- Go a bit smoother. You should remove them before moving into a
- Production environment.
- Remove anonymous users? [y/n] y remove test User: Y Yes
- ... success!
- Normally, Root should only is allowed to connect from ' localhost '. This
- Ensures that someone cannot guess at the root of password from the network.
- Disallow Root login remotely? [y/n] Y allows root telnet: N not allowed
- ... success!
- By default, MariaDB comes with a database named ' test ' that anyone can
- Access. This was 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 Erase test Database test:y Delete
- -Dropping test database ...
- ... success!
- -Removing privileges on test database ...
- ... success!
- Reloading the privilege tables would ensure that all changes made so far
- would take effect immediately.
- Reload privilege tables now? [y/n] Y reload permission table: Y Reload
- ... success!
- Cleaning up ...
- All done! If you ' ve completed all of the above steps, your MariaDB
- Installation should now is secure.
- Thanks for using MariaDB
3. View the status of the MARIADB database service (It also shows that mariadb and other MySQL databases cannot coexist on the same operating system)
- [Email protected]:~$ sudo systemctl status MySQL
4. Start the MARIADB database service
- [Email protected]:~$ sudo systemctl start MySQL
3. Set up MySQL to boot with system service
- [email protected]:~$ sudo update-rc.d mysql defaults
4. Revoke the boot with system service
- [email protected]:~$ sudo update-rc.d-f mysql remove
5. Unlike the previous version of MySQL, you need to gain operating system administrator privileges to log on to mariadb root user, normal operating system users cannot log on to the MARIADB database root user
- [Email protected]:~$ sudo mysql-u root-p
6. Backing up the MySQL database also requires an operating system administrator to perform the backup
- [email protected]:~$ sudo mysqldump-uroot-p mysql >mysql.sql
7. Create a normal database user ( login to normal database users do not need to gain operating system administrator privileges)
- Create user ' ZHANGDC ' @'% ' identified by ' 1 '; (The following number is the password can be set by itself)
8. Log in to remote database (requires [email protected] '% ')
- [Email protected]:~$ mysql-h localhost-u HENRY-P1
9. Modify the MARIADB configuration file and monitor the extranet access
- [Email protected]:~$ sudo vim/etc/mysql/mariadb.conf.d/50-server.cnf
# Instead of skip-networking The default is now-listen only on
# localhost which are more compatible and are not less secure.
#bind-address = 127.0.0.1 #注释掉这一行
10. Restart the database service for the configuration to take effect
- [Email protected]:~$ sudo systemctl restart MySQL
Version 11.MariaDB
- [Email protected]:~$ mysql-v
- MySQL Ver 15.1 distrib 10.0.29-mariadb, for Debian-linux-gnu (x86_64) using ReadLine 5.2
"Ubuntu 16.04.3 LTS" Apt-get installation mariadb