Linux下如何安装数据库管理系统MariaDB
小编给大家分享一下Linux下如何安装数据库管理系统MariaDB,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
MariaDB数据库管理系统是 MySQL 的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。
yuminstallmariadb-servermariadb-y
查看版本
[root@mysqldb~]#rpm-qmariadb-servermariadbmariadb-server-5.5.60-1.el7_5.x86_64mariadb-5.5.60-1.el7_5.x86_64设置开机自启动
[root@mysqldb~]#systemctlenablemariadbCreatedsymlinkfrom/etc/systemd/system/multi-user.target.wants/mariadb.serviceto/usr/lib/systemd/system/mariadb.service.配置安全脚本
安装完后,root密码默认是空,因此需要进行配置安全控制程序。
配置前需要先启动mariadb
systemctlstartmariadb
启动安全配置程序
[root@mysqldb~]#mysql_secure_installationNOTE:RUNNINGALLPARTSOFTHISSCRIPTISRECOMMENDEDFORALLMariaDBSERVERSINPRODUCTIONUSE!PLEASEREADEACHSTEPCAREFULLY!InordertologintoMariaDBtosecureit,we'llneedthecurrentpasswordfortherootuser.Ifyou'vejustinstalledMariaDB,andyouhaven'tsettherootpasswordyet,thepasswordwillbeblank,soyoushouldjustpressenterhere.Entercurrentpasswordforroot(enterfornone):#密码是空,回车即可。OK,successfullyusedpassword,movingon...SettingtherootpasswordensuresthatnobodycanlogintotheMariaDBrootuserwithouttheproperauthorisation.Setrootpassword?[Y/n]y#是否设置root密码,这里进行设置Newpassword:Re-enternewpassword:Passwordupdatedsuccessfully!Reloadingprivilegetables.....Success!Bydefault,aMariaDBinstallationhasananonymoususer,allowinganyonetologintoMariaDBwithouthavingtohaveauseraccountcreatedforthem.Thisisintendedonlyfortesting,andtomaketheinstallationgoabitsmoother.Youshouldremovethembeforemovingintoaproductionenvironment.Removeanonymoususers?[Y/n]y#删除匿名用户...Success!Normally,rootshouldonlybeallowedtoconnectfrom'localhost'.Thisensuresthatsomeonecannotguessattherootpasswordfromthenetwork.Disallowrootloginremotely?[Y/n]n#允许root远程登陆数据库...skipping.Bydefault,MariaDBcomeswithadatabasenamed'test'thatanyonecanaccess.Thisisalsointendedonlyfortesting,andshouldberemovedbeforemovingintoaproductionenvironment.Removetestdatabaseandaccesstoit?[Y/n]n#不删除test数据库,后面测试可以使用...skipping.Reloadingtheprivilegetableswillensurethatallchangesmadesofarwilltakeeffectimmediately.Reloadprivilegetablesnow?[Y/n]y#重载授权表...Success!Cleaningup...Alldone!Ifyou'vecompletedalloftheabovesteps,yourMariaDBinstallationshouldnowbesecure.ThanksforusingMariaDB!
按照上面的提示进行配置,大致就ok了。
登陆数据库上面已经设置了密码,因此不能只通过mysql就登陆数据库,后面必须加上用户和密码。
[root@mysqldb~]#mysql-uroot-pEnterpassword:#输出密码,不建议放在-p后面明文显示WelcometotheMariaDBmonitor.Commandsendwith;or\g.YourMariaDBconnectionidis9Serverversion:5.5.60-MariaDBMariaDBServerCopyright(c)2000,2018,Oracle,MariaDBCorporationAbandothers.Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.MariaDB[(none)]>基本命令
查看数据库
showdatabases;
进入数据库
usemysql;
查看表列表
showtables;
查看表结构
descuser;
查看版本:
MariaDB[mysql]>selectversion();+----------------+|version()|+----------------+|5.5.60-MariaDB|+----------------+1rowinset(0.00sec)目录结构目录 说明 /var/lib/mysqlmysql数据文件存放路径,可以自定义/etc/my.cnfmysql配置文件地址/usr/lib64/mysqlmysql库文件路径/usr/bin/mysql*mysql二进制可执行文件路径/etc/rc.d/init.d/mysqldmysql服务管理脚本地址/var/log/mysqld.logmysql日志文件地址
以上是“Linux下如何安装数据库管理系统MariaDB”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。