Mariabd 平安配置向导
**1. 装置完 mariadb-server 后,运行 mysql_secure_installation 去除安全隐患
mysql_secure_installation 会执行几个设置:**
- 为 root 用户设置明码
- 删除匿名账号
- 勾销 root 用户近程登录
- 删除 test 库和对 test 库的拜访权限
- 刷新受权表使批改失效
[root@xuegod63 ~]# mysql_secure_installation #进入平安配置向导
** 通过这几项的设置可能进步 MySQL 库的平安。倡议生产环境中 MySQL 装置实现后肯定要运
行一次 mysql_secure_installation,具体步骤请参看上面的命令:**
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, 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): #首次运行间接回车,因为 root 用户没有明码
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y #是否设置 root 用户明码, 输出 Y
New password: 123456 #新密码 123456
Re-enter new password: 123456
Password updated successfully!。。。Remove anonymous users? [Y/n] Y #是否删除匿名用户, 生产环境倡议删除,所以间接回车或 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 #是否禁止 root 近程登录, 依据本人的需要抉择
Y/ n 并回车, 倡议禁止
... 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 #是否删除 test 数据库, 间接回车或 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 明码
[root@xuegod63 ~]# mysqladmin -u root password "123456"
2. 数据库连贯
连贯 MariaDB 数据库,连贯本机能够去掉 - h 选项
# mysql #如 MariaDB 没有设置明码,并在本地上登录,而且是应用默认端口的状况
下,能够间接应用 mysql 命令登录。或:# mysql -h IP -u USER -pPASS #如 MariaDB 不是装置在本地时,须要应用 - h 选项指定
IP 登录,如 MariaDB 用户设置了明码时,须要应用 - u 选项指定用户,并应用 - p 选项指定明码,留神的是
在 - p 选项和明码之间不能有空格,否则在命令执行后须要再次输出明码,并将有空格的明码串辨认为登录
的数据库。MariaDB 的超级管理员是 root 用户,领有 MariaDB 数据库的最高权限。
3. 测试数据是否失常
[root@xuegod63 ~]# mysql -u root -p123456
MariaDB [(none)]> show databases; #没有 test 数据库 #执行时,所有命令以;号结尾
+-------------------------+
| Database |
+-------------------------+
| information_schema |
| mysql |
| ucenter |
+-------------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]> exit #退出命令能够加分号,也能够不加分号。
4. 测试网站是否反对 PHP
[root@xuegod63 ~]# cd /var/www/html/
[root@xuegod63 html]# vim index.php
<?php
phpinfo();
?>
[root@xuegod63 html]# systemctl restart httpd #重启 httpd 服务。[root@xuegod63 html]# iptables -F #清空防火墙
测试:
http://192.168.1.63/index.php
LAMP 网站架构搭建实现
到此 MySQL 数据库装置胜利
小伙伴想要获取学习视频 + 笔记材料的
请增加咱们小姐姐
咱们也有 Windows 上装置 mysql 教程哦!