centos下操作

0x001 安装和启动mysql


其实已经换成mariadb了;

  1. 搜索:yum list|grep mariadb
  2. 安装:yum install mariadb mariadb-server`
  3. 启动:service mariadb start
  4. 开机自动启动:systemctl enable mariadb

0x002 初始化密码mysql


  1. 切换数据库: use mysql
  2. 设置新密码:update user set password =PASSWORD('rooter') where user ='root';
  3. flush privileges

0x003 开启远程连接mysql


  1. GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'rooter' WITH GRANT OPTION;
  2. flush privileges

0x004 开启ssh

--

  1. 查看是否安装ssh:rpm -qa | grep ssh
  2. 未安装:yum install openssh-server
  3. 启动:service sshd start
  4. 开机启动:chkonfig sshd on(off 是关闭)

0x005 开启apahce


  1. 查看是否安装ssh:rpm -qa | grep httpd
  2. 未安装:yum install httpd
  3. 启动:service httpd start

    sudo usr/sbin/apachectl -k start

  4. 开机启动:chkonfig httpd on(off 是关闭)
  5. 默认项目目录:/var/www/html

0x006 开启php


1.安装php:yum install php php-mysql
2.重启apache:service httdp restart

  1. 测试数据库链接:
    $servername = "localhost";
    $username = "username";
    $password = "password";

     // 创建连接
     $conn = new mysqli($servername, $username, $password);
    
     // 检测连接
     if ($conn->connect_error) {
         die("连接失败: " . $conn->connect_error);
     } 
     echo "连接成功";
     ?>

你可能感兴趣的:(centos下操作)