PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
-- SELECT user, host FROM mysql.user; SHOW DATABASES; SHOW PROCESSLIST; SHOW GRANTS; -- echo "CREATE USER "${domain}"@"localhost" IDENTIFIED BY \"${dbup}\";" | mysql -u root -p"${dbrp}" -- echo "CREATE DATABASE ${domain};" | mysql -u root -p"${dbrp}" -- echo "GRANT ALL PRIVILEGES ON ${domain}.* TO ${domain}@localhost;" | mysql -u root -p"${dbrp}" -- CREATE USER domain @ localhost IDENTIFIED BY dbup; | mysql -u root -p dbrp -- CREATE DATABASE domain; | mysql -u root -p dbrp -- GRANT ALL PRIVILEGES ON domain.* TO domain @localhost; | mysql -u root -p dbrp -- SELECT * FROM information_schema.processlist; -- SELECT ID , user, host, db, command -- FROM information_schema.processlist -- WHERE ID = CONNECTION_ID(); -- CREATE USER IF NOT EXISTS 'emp_read_only'@'localhost' IDENTIFIED BY 'TestPassword'; -- SELECT * FROM mysql.user; -- SELECT user(); -- SELECT current_user(); -- SELECT DATABASE(); DROP TABLE IF EXISTS `student1`; CREATE TABLE `student1` ( `id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(15) DEFAULT NULL, `sex` char(4) DEFAULT NULL, `address` varchar(20) DEFAULT NULL, `hobby` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `student2`; CREATE TABLE `student2` ( `id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(15) DEFAULT NULL, `sex` char(4) DEFAULT NULL, `address` varchar(20) DEFAULT NULL, `hobby` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; CREATE TEMPORARY TABLE student3 ( `id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(15) DEFAULT NULL, `sex` char(4) DEFAULT NULL, `address` varchar(20) DEFAULT NULL, `hobby` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; DESC student1; -- SHOW DATABASES; SHOW TABLES; -- use information_schema; -- SHOW TABLES; -- use sakila; -- SHOW TABLES; -- SELECT DATABASE(); /* -- 创建临时表 CREATE TEMPORARY TABLE temp_orders AS SELECT * FROM orders WHERE order_date >= '2023-01-01'; -- 查询临时表 SELECT * FROM temp_orders; -- 插入数据到临时表 INSERT INTO temp_orders (order_id, customer_id, order_date) VALUES (1001, 1, '2023-01-05'); -- 查询临时表 SELECT * FROM temp_orders; -- 删除临时表 DROP TEMPORARY TABLE IF EXISTS temp_orders; */
Copy Clear
Copy Format Clear
<?php try { echo date('Y-m-d H:i:s').PHP_EOL.PHP_EOL; echo'Connect ...'.PHP_EOL.PHP_EOL; //$servername = 'localhost:3306' ; //MySQL的host主机名,一般是3306 port //$username = '98f8193e8e4adaaf62a31104bfc736c4' ; //MySQL的用户名,root等级最高,可以用别的 //$password = 'root' ; //MySQL的对应用户的密码,自己看 // $conn = new_mysqli( $servername, $username, $password); $conn = $mysqli; if($conn->connect_error){ //检测PHP的连接(connect_error字符串有东西吗) die('Connect Failed:'.$conn->connect_error); //报告错误并结束 } echo'Connect success!'; // 查询数据库 $sql = "SELECT * FROM users WHERE username = ?"; $stmt = $conn->prepare($sql); // $stmt->bind_param('s', $username); // $stmt->execute(); // $result = $stmt->get_result(); // // 输出查询结果 // if ($result->num_rows > 0) { // while ($row = $result->fetch_assoc()) { // echo "用户名: " . $row["username"]. " 密码: " . $row["password"]. ""; // } // } else { // echo "没有找到用户"; // } // 关闭连接 // $stmt->close(); // $conn->close(); } catch (mysqli_sql_exception $e) { die ("Error!: " . $e->getMessage() . "<br/>"); } ?>
Show:  
Copy Clear