Mysql的基础使用之MariaDB安装方法详解
程序员文章站
2023-12-18 17:15:04
我首次用mysql是在ubuntu上,现在用的是linux 中的red hat 分支的centos 7 ,安装时发现通常用的都是mariadb 来代替mysql,通过资料查...
我首次用mysql是在ubuntu上,现在用的是linux 中的red hat 分支的centos 7 ,安装时发现通常用的都是mariadb 来代替mysql,通过资料查询发现mariadb是mysql的其中的一种分支,由mysql的创始人带领的团队所开发的mysql分支的一种版本,因为mysql受到被oracle收购后的日渐封闭与缓慢的更新,众多linux发行版逐渐抛弃了这个人气开源数据库,使mysql在各大linux发行版中的失势由于不满mysql被oracle收购后的日渐封闭与缓慢的更新,众多linux发行版逐渐抛弃了这个人气开源数据库,而转向了mariadb,虽然postgresql一直被当作mysql的直接竞争对手,然而真正给予其致命一击的似乎更像是mariadb,而以后给mysql致命一击的也将是mariadb。
言归正传,我们来具体讲讲mariadb ,其实mariadb的操作与mysql的操作基本一样,只是基于mysql进行了性能的提升,目前mariadb的更新速度已经远远超越了oracle团队的速度,毕竟是mysql创始人带领的团队,怎么不让人放心。
mariadb的安装
linux下 通过
yum install mariadb mariadb-server #询问是否要安装,输入y即可自动安装
mariadbde 服务的基本命令
[root@127 ~]# systemctl start mariadb.service #启动mariadb [root@127 ~]# systemctl stop mariadb.service #停止mariadb [root@127 ~]# systemctl restart mariadb.service #重启mariadb [root@127 ~]# systemctl enable mariadb.service #设置开机自动启动 [root@127 ~]# systemctl disenable mariadb.service #设置开机自启关闭
初始化root密码
[root@127 ~]# mysql_secure_installation #为初始化账户root添加密码 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):这里填写root密码,如果是第一次初始化密码为空直接敲回车(回车前)
enter current password for root (enter for none):这里填写root密码,如果是第一次初始化密码为空直接敲回车 (回车后↓) 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 have a root password set, so you can safely answer 'n'. change the root password? [y/n] y 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] y ... success! 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] y - dropping test database... error 1008 (hy000) at line 1: can't drop database 'test'; database doesn't exist ... failed! not critical, keep moving... - removing privileges on test database... ... success! 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!# 这里表示修改密码成功
数据库登录
[root@127 ~]# mysql -uroot -proot # mysql -u这里是填写的用户名(默认为root) &我是空格& -p这里填写的是密码(默认为空)
这表示已经进入mariadbwelcome to the mariadb monitor. commands end with ; or \g. your mariadb connection id is 23 server version: 5.5.50-mariadb mariadb server copyright (c) 2000, 2016, oracle, mariadb corporation ab and others. type 'help;' or '\h' for help. type '\c' to clear the current input statement. # 通过/h可以查看很多命令 mariadb [(none)]> 这里是输入sql语句的入口
以上是mariadb的安装
以上所述是小编给大家介绍的mysql的基础使用之mariadb安装方法详解,希望对大家有所帮助
推荐阅读