参考链接:http://www.linuxidc.com/Linux/2016-03/128880.htm
安装mariadb
1. 搜索安装包
cmd:yum search mariadb
mariadb-bench.x86_64
mariadb-embedded-devel.i686
mariadb-embedded.x86_64
mariadb-server.x86_64
mariadb-devel.i686
mariadb-embedded-devel.x86_64 mariadb-libs.i686
mariadb-test.x86_64
mariadb-devel.x86_64
mariadb-embedded.i686
mariadb-libs.x86_64
mariadb.x86_64
2. 选择安装包安装(这里安装几个)
cmd:yum install -y mariadb-server.x86_64 mariadb-devel.x86_64 mariadb-libs.x86_64 mariadb.x86_64
3. 开机启动 & 启动服务
3.1 开机启动
cmd:systemctl enable mariadb
3.2 启动服务
cmd:service mariadb start
4. 简单配置mariadb
cmd:mysql_secure_installation
4.1 设置密码,会提示先输入密码
Enter current password for root (enter for none):<–初次运行直接回车
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
4.2 其他配置
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
4.3 初始化MariaDB完成,我们来测试登录
cmd:mysql -u用户名 -p密码
可能遇到的问题
比如这个问题:“Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.”
解决办法
1. 输入命令 service mariadb status
比如是这个样子:
systemd[1]: Starting MariaDB database server...
mysqld_safe[2155]: 160127 17:01:08 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
mysqld_safe[2155]: 160127 17:01:08 mysqld_safe Starting mysqld daemon with databases from...mysql
systemd[1]: mariadb.service: control process exited, code=exited status=1
systemd[1]: Failed to start MariaDB database server.
systemd[1]: Unit mariadb.service entered failed state.
systemd[1]: mariadb.service failed.
2. 删除文件
cmd:rm -f /var/lib/mysql/ib_logfile