欢迎光临
一个废柴的博客

CentOS使用yum安装mariadb

环境:

  • digitalocean CentOS 7.4 x64
  • mariadb:10.1.32

首先新建一个文件:sudo vi /etc/yum.repos.d/MariaDB.repo,编辑内容如下:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

然后执行安装命令:

sudo yum install -y MariaDB-server MariaDB-client

检查是否开机自启:

sudo systemctl is-enabled mariadb.service

检查启动状态:

sudo systemctl status mariadb.service

启动服务:

sudo systemctl start mariadb #立刻启动
sudo systemctl enable mariadb #开机启动
sudo systemctl status mariadb #查看服务状态

设置root密码:

/usr/bin/mysqladmin -u root password '1234567890'

通过修改mysql.user表的方式重新修改一下root密码,并配置实现远程连接:

$ /usr/bin/mysql -u root -p
Enter password:  输入你刚刚设置的密码

MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> UPDATE user SET password=PASSWORD('你的密码') WHERE User='root';

#为root数据库用户添加本地访问所有数据库的权限
MariaDB [mysql]> grant all privileges  on *.* to [email protected]'localhost' identified by "1234567890";
Query OK, 0 rows affected (0.00 sec)

#为root数据库用户添加远程连接访问所有数据库的权限
MariaDB [mysql]> grant all privileges  on *.* to [email protected]'%' identified by "1234567890";
Query OK, 0 rows affected (0.00 sec)

#最后刷新权限
MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

至此,mariadb安装完毕。

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址