环境:
- 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密码:
sudo /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 root@'localhost' identified by "1234567890";
Query OK, 0 rows affected (0.00 sec)
#为root数据库用户添加远程连接访问所有数据库的权限
MariaDB [mysql]> grant all privileges on *.* to root@'%' identified by "1234567890";
Query OK, 0 rows affected (0.00 sec)
#最后刷新权限
MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
至此,mariadb安装完毕。
参考:
最新评论
我的是ipv4网络,如何使用直播源啊!
我今天试了,不想啊,我的是新疆昌吉移动的网络。
收不到验证码电报
现在充值29起了