本文在Centos7.6下介紹mysql的分支mariadb的安裝方法和過程。mysql
yum install mariadb-server mariadb -y
查看版本sql
[root@mysqldb ~]# rpm -q mariadb-server mariadb mariadb-server-5.5.60-1.el7_5.x86_64 mariadb-5.5.60-1.el7_5.x86_64
[root@mysqldb ~]# systemctl enable mariadb Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
安裝完後,root密碼默認是空,所以須要進行配置安全控制程序。數據庫
配置前須要先啓動mariadb安全
systemctl start mariadb
啓動安全配置程序測試
[root@mysqldb ~]# 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 #是否設置root密碼,這裏進行設置 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] n #容許root遠程登錄數據庫 ... skipping. 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] n #不刪除test數據庫,後面測試能夠使用 ... skipping. 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!
按照上面的提示進行配置,大體就ok了。日誌
上面已經設置了密碼,所以不能只經過mysql就登錄數據庫,後面必須加上用戶和密碼。code
[root@mysqldb ~]# mysql -u root -p Enter password: #輸出密碼,不建議放在-p後面明文顯示 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 9 Server version: 5.5.60-MariaDB MariaDB Server 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)]>
查看數據庫orm
show databases;
進入數據庫server
use mysql;
查看錶列表ip
show tables;
查看錶結構
desc user;
查看版本:
MariaDB [mysql]> select version(); +----------------+ | version() | +----------------+ | 5.5.60-MariaDB | +----------------+ 1 row in set (0.00 sec)
目錄 | 說明 |
---|---|
/var/lib/mysql | mysql數據文件存放路徑,能夠自定義 |
/etc/my.cnf | mysql配置文件地址 |
/usr/lib64/mysql | mysql庫文件路徑 |
/usr/bin/mysql* | mysql二進制可執行文件路徑 |
/etc/rc.d/init.d/mysqld | mysql服務管理腳本地址 |
/var/log/mysqld.log | mysql日誌文件地址 |
本文只是簡單介紹一下安裝的過程,方便進行一些簡單的測試。