phpmyadmin配置:
# 将包下载并解压至/www/host2/htdoc
# cd 到 文件目录
# 创建符号连接
[root@johnson's linux htdoc]# ln -s phpMyAdmin-4.4.14.1-all-languages myadmin
[root@johnson's linux htdoc]# ls
index.php phpMyAdmin-4.4.14.1-all-languages
myadmin phpMyAdmin-4.4.14.1-all-languages.zip
#cd 至myadmin 目录里面,修改配置文件
[root@johnson's linux htdoc]# cp config.sample.inc.php config.inc.php
#编辑配置文件
[root@johnson's linux htdoc]# vim config.inc.php
$cfg['blowfish_secret'] = 'o71mI9rimj6syc00fT3g'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
#单引号填写随机密码,可使用openssl rand -base64 15(密码长度)生成
/*
* Servers configuration
*/
$i = 0;
/*
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '172.18.17.8'; # 数据库主机ip
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false; 172.18.17.8主机配置:mysql服务
(1)yum安装程序
[root@johnson's linux ~]# yum install mariadb-server
========================================================================================
Installing:
mariadb-server x86_64 1:5.5.44-2.el7.centos base 11 M
Installing for dependencies:
mariadb x86_64 1:5.5.44-2.el7.centos base 8.9 M
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k
perl-DBD-MySQL x86_64 4.023-5.el7 base 140 k
perl-DBI x86_64 1.627-4.el7 base 802 k
perl-IO-Compress noarch 2.061-2.el7 base 260 k
perl-Net-Daemon noarch 0.48-5.el7 base 51 k
perl-PlRPC noarch 0.2020-14.el7 base 36 k
Transaction Summary
======================================================================================== 一大推依赖包,只要有yum在且yum源配置没有问题,可以轻松解决
(2)启动服务,执行安全安装操作
[root@johnson's linux ~]# systemctl start mariadb
# 查看监听端口,3306为mariaDB的默认监听端口
[root@johnson's linux ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 *:3306 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 :::22 :::*
执行安全安装操作
[root@johnson's linux ~]# mysql_secure_installation
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y # 设置管理员登陆秘密(此密码和linux系统的root没关系)
New password:
Re-enter new password: # 输入密码即可
Password updated successfully!
Reloading privilege tables..
... Success!
Remove anonymous users? [Y/n] y # 是否移除匿名用户(在执行安全安装之前不需要密码登陆)
... Success! # 允许匿名登陆时很危险的,建议移除
Disallow root login remotely? [Y/n] n # 是否不允许管理员账号远程登陆,一般情况下建议不允许
... skipping.
Remove test database and access to it? [Y/n] y # 移除测试数据库
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y # 重载权限表
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB! 强烈建议在mariaDB安装完成后执行安全安装操作,这样可以使得数据库更安全
(3)创建所需数据库并授权
[root@johnson's linux ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 66
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)]> CREATE DATABASE wpdb; # 创建wordpress的数据库
Query OK, 1 row affected (0.02 sec)
# 授权wordpress数据库
MariaDB [(none)]> GRANT ALL ON wpdb.* TO wpuser@172.18.17.7 IDENTIFIED BY 'wppasswd';
Query OK, 0 rows affected (0.01 sec)
#授权远程访问主机(phpMyadmin)
MariaDB [(none)]> GRANT ALL ON *.* TO admin@'172.18.17.7' IDENTIFIED BY 'admin';
Query OK, 0 rows affected (0.01 sec)