linux-运维进阶-26 使用phpmyadmin管理数据库
使用phpMyAdmin管理数据库
安装必须的组件
[root@localhost ~]# yum -y install httpd php mariadb mariadb-server php-mysql php-mbstring php-mcrypt unzip
获得phpmyadmin软件包并且解压和移动路径
[root@localhost ~]# wget https://files.phpmyadmin.net/phpMyAdmin/4.1.0/phpMyAdmin-4.1.0-all-languages.zip
[root@localhost ~]# ls
anaconda-ks.cfg phpMyAdmin-4.1.0-all-languages.zip
[root@localhost ~]# unzip phpMyAdmin-4.1.0-all-languages.zip
[root@localhost ~]# ls
anaconda-ks.cfg phpMyAdmin-4.1.0-all-languages phpMyAdmin-4.1.0-all-languages.zip
[root@localhost ~]# mv phpMyAdmin-4.1.0-all-languages /var/www/html/phpmyadmin
[root@localhost ~]# ls /var/www/html/
phpmyadmin
[root@localhost ~]#
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# chown -R apache:apache phpmyadmin
[root@localhost html]# chmod 755 -R phpmyadmin
[root@localhost html]#
配置phpmyadmin
[root@localhost html]# cd phpmyadmin/
[root@localhost phpmyadmin]# cp config.sample.inc.php config.inc.php
[root@localhost phpmyadmin]# vim config.inc.php
我们在$cfg['blowfish_secret'] = ''的引号中任意写入一串字符,大家可以把它理解为一个身份验证码。
第17行:
17 $cfg['blowfish_secret'] = 'abcdefg';
保存退出
运行phpmyadmin
[root@localhost phpmyadmin]# cd
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# firewall-cmd --add-port=80/tcp --permanent
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# setenforce 0
初始化数据库
- 设置root管理员在数据库中的密码值(注意,该密码并非root管理员在系统中的密码,这里的密码值默认应该为空,可直接按回车键)。
- 设置root管理员在数据库中的专有密码。
- 随后删除匿名账户,并使用root管理员从远程登录数据库,以确保数据库上运行的业务的安全性。
- 删除默认的测试数据库,取消测试数据库的一系列访问权限。
- 刷新授权列表,让初始化的设定立即生效。
[root@localhost ~]# systemctl restart mariadb.service
[root@localhost ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
#这里直接敲回车
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
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!
[root@localhost ~]#
浏览器打开服务器Server的IP地址,如下图:
在后面追加/phpmyadmin,如下图:
用root和刚刚初始化数据库的密码登录上去
在这里,你可以很方便的建表查表等完成对数据库的操作,具体就靠你自己去玩玩熟了。
本篇到此结束。