1. 程式人生 > >centos7使用yum直接安裝mariadb

centos7使用yum直接安裝mariadb

在centos7系統下,預設安裝mariadb的版本是5.5

1、安裝mariadb

1 yum install mariadb mariadb-server

2、啟動mariadb並設定開機自啟

12 systemctl start mariadbsystemctl enable mariadb

3、初始化mariadb

1 mysql_secure_installation
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 NOTE:RUNNING ALL PARTS OF THISSCRIPT ISRECOMMENDED FORALL MariaDBSERVERS INPRODUCTION USE!PLEASE READ EACHSTEP CAREFULLY!Inorder tolog into MariaDB tosecure
it,we'll need the currentpassword for the root user.  If you've just installed MariaDB,andyou 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 MariaDBroot user without the proper authorisation.Set root password? [Y/n] y #是否設定root使用者密碼,輸入y或者直接回車,設定密碼New password: Re-enter new password: Password updated successfully!Reloading privilege tables.. ... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] #是否刪除匿名使用者,輸入y或者直接回車 ... Success!Normally, root should only be allowed to connect from 'localhost'.  Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] #是否禁止root遠端登入,輸入y或者直接回車 ... Success!By default, MariaDB comes with a database named 'test' that anyone canaccess.  This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] #是否刪除test測試資料庫,輸入y或者直接回車 - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill 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 MariaDBinstallation should now be secure.Thanks forusing MariaDB!

4、最後驗證下資料庫是否可以成功登入

1 mysql-uroot-p
1234567891011121314151617 Welcome tothe MariaDB monitor.Commands endwith;or\g.Your MariaDB connection id is11Server version:5.5.60-MariaDB MariaDB ServerCopyright(c)2000,2018,Oracle,MariaDB Corporation Ab andothers.Type'help;'or'\h'forhelp.Type'\c'toclear the current input statement.MariaDB[(none)]>show databases;+--------------------+|Database|+--------------------+|information_schema||mysql||performance_schema|+--------------------+3rows inset(0.00sec)
0