版本信息:
CentOS 7.2 64位
CentOS(Community Enterprise Operating System,中文意思是:社区企业操作系统)是Linux发行版之一,它是来自于Red Hat Enterprise Linux依照开放源代码规定释出的源代码所编译而成。由于出自同样的源代码,因此有些要求高度稳定性的服务器以CentOS替代商业版的Red Hat Enterprise Linux使用。两者的不同,在于CentOS并不包含封闭源代码软件。目前最新版本是CentOS 7.3.1708
方法1:安装
MariaDB
数据库
- 安装
yum install mariadb-server mariadb
# mariadb数据库的相关命令是:
#启动MariaDB
systemctl start mariadb
#停止MariaDB
systemctl stop mariadb
#重启MariaDB
systemctl restart mariadb
#设置开机启动
systemctl enable mariadb
- 为root账户设置密码
# MariaDB安装好后默认是没有密码的,如何为root账号为密码
#先启动数据库
systemctl start mariadb
#进入数据库,不需要账号密码都可以直接进入
mysql
show databases;
use mysql;
update user set password=password("123456")where user='root';
flush privileges;
exit;
# 测试:在命令行输入mysql,不带登录信息
#报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
mysql
# ok,成功进入数据库
mysql -uroot -p123456
若发现MySQL只有information_schema,test两个数据库,则应该使用sudo -s
命令后再进入数据库!
参考链接:MySQL只有information_schema,test两个数据库
- 让mysql支持远程访问
方法1:用SSH形式登录
方法2:授权登录
mysql -uroot -proot;
use mysql;
select user,host,password from user;
# 使用账号root+密码123456从任何主机连接到mysql服务器
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
授权后,在Navicat上链接MySQL如连接本地MySQL一样即可,吧localhost改成ip即可!
用Navicat链接数据库(SSH形式)
参考链接
centos7 mysql数据库安装和配置:https://www.cnblogs.com/starof/p/4680083.html
centos7 mariadb设置初始密码:http://blog.csdn.net/hyq776141352/article/details/69808662