CentOS7安装Apache+PHP+MariaDB

首先,安装Apache服务器

yum install httpd

第二,安装PHP及常用软件包

yum install php httpd-manual mod_ssl mod_perl mod_auth_mysql
yum install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
yum install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

第三,安装MariaDB

yum install mariadb* 

第四,启动服务

systemctl start httpd.service
systemctl start mariadb.service

第五,如果第四部成功,则设置两个服务自动启动

systemctl enable httpd.service
systemctl enable mariadb.service

第六,设置数据库服务器

[root@rachel ~]#  mysql -u root #无密码登录数据库
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> select user, host, password from mysql.user; #检索数据库用户
+------+--------------+----------+
| user | host         | password |
+------+--------------+----------+
| root | localhost    |          |
| root | rachel       |          |
| root | 127.0.0.1    |          |
| root | ::1          |          |
|      | localhost    |          |
|      | rachel       |          |
+------+--------------+----------+
6 rows in set (0.00 sec)

MariaDB [(none)]> delete from mysql.user where user='';
Query OK, 2 rows affected (0.00 sec) #删除匿名用户

MariaDB [(none)]> delete from mysql.user where user='root' and host='::1'; #删除IPv6方式登录用户
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> select user, host, password from mysql.user;  #再次查看用户
+------+--------------+----------+
| user | host         | password |
+------+--------------+----------+
| root | localhost    |          |
| root | rachel       |          |
| root | 127.0.0.1    |          |
+------+--------------+----------+
3 rows in set (0.00 sec)

MariaDB [(none)]> set password for root@localhost=password('XXXXXX');  #修改本地登录密码
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> set password for root@rachel=password('XXXXXX');  #修改本地登录密码
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> set password for root@'127.0.0.1'=password('XXXXXX');  #修改本地登录密码
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> select user, host, password from mysql.user; #查看密码
+------+--------------+-------------------------------------------+
| user | host         | password                                  |
+------+--------------+-------------------------------------------+
| root | localhost    | *1728FCC102D8D1EB12BFXXXXXXXXXXXXXXXXXXX |
| root | rachel       | *1728FCC102D8D1EB12BFXXXXXXXXXXXXXXXXXXX |
| root | 127.0.0.1    | *1728FCC102D8D1EB12BFXXXXXXXXXXXXXXXXXXX |
+------+--------------+-------------------------------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> exit #退出
Bye
[root@rachel ~]# mysql -u root -p #再次用密码登录测试
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> exit
Bye
[root@rachel ~]# #测试成功
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

田辛 | 田豆芽

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值