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 MySQLSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MySQL to secure it, we'll need the currentpassword for the root user. If you've just installed MySQL, andyou 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 MySQLroot user without the proper authorisation.Set root password? [Y/n] Y #是否设置root用户明码,输出YNew password: 123456 #新密码123456Re-enter new password: 123456Password updated successfully!。。。Remove anonymous users? [Y/n] Y #是否删除匿名用户,生产环境倡议删除,所以间接回车或 Y... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures 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 canaccess. This is also intended only for testing, and should be removedbefore 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 farwill 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 MariaDBinstallation 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教程哦!