当我通过 xampp 运行我的代码时,我一直遇到这个错误。即使在启动 MySQL 和 Apache 之后警告: mysqli_connect(): (HY000/1049): Unknown database 'loginsystem' in C:\xampp\htdocs\dbconnection.php on line 6 Failed to connect to MySQL: Unknown database 'loginsystem'这是我的 db.connection 代码<?phpdefine('DB_SERVER','localhost');define('DB_USER','root');define('DB_PASS' ,'');define('DB_NAME', 'loginsystem');$con = mysqli_connect(DB_SERVER,DB_USER,DB_PASS,DB_NAME);// Check connectionif (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } ?>loginsystem.sql-- phpMyAdmin SQL Dump-- version 4.8.4-- https://www.phpmyadmin.net/---- Host: 127.0.0.1-- Generation Time: Mar 24, 2019 at 05:58 PM-- Server version: 10.1.37-MariaDB-- PHP Version: 7.3.0SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";SET AUTOCOMMIT = 0;START TRANSACTION;SET time_zone = "+00:00";/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;/*!40101 SET NAMES utf8mb4 */;---- Database: `loginsystem`---- ------------------------------------------------------------ Table structure for table `admin`--CREATE TABLE `admin` (`id` int(11) NOT NULL, `username` varchar(255) NOT NULL,`password` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ---- Dumping data for table `admin`--INSERT INTO `admin` (`id`, `username`, `password`) VALUES(1, 'admin', 'dd077f889d7e3641bf9cc0e64b157918'); -- ------------------------------------------------------------ Table structure for table `off`--CREATE TABLE `off` (`id` int(11) NOT NULL,`dateoff` date NOT NULL,`timeoff` text NOT NULL,`dateback` date NOT NULL,`timeback` text NOT NULL,`reason` text NOT NULL,`status` text NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1;我不断收到此错误。它不允许我登录警告: mysqli_connect(): (HY000/1049): Unknown database 'loginsystem' in C:\xampp\htdocs\dbconnection.php on line 6 Failed to connect to MySQL: Unknown database 'loginsystem'
1 回答
翻过高山走不出你
TA贡献1875条经验 获得超3个赞
您可能尚未在 mySQL 服务器中创建数据库。
您需要连接到您的 MySQL 服务器运行 CREATE DATABASE loginsystem;
- 1 回答
- 0 关注
- 402 浏览
添加回答
举报
0/150
提交
取消