LoginSignup
0
0

More than 3 years have passed since last update.

webarenaでubuntu その51

Last updated at Posted at 2019-09-26

概要

webarenaでubuntu18.04やってみた。
練習問題やってみた。

練習問題

phpで使えるデーターベースを準備せよ。

mysqlをインストール。

sudo apt-get install mysql-server php-mysql

mysql_secure_installationを実行。

mysqlに入る。

mysql -u root -p 

databaseを作る。

CREATE DATABASE mydb;

userを作る。

CREATE USER 'user0'@'localhost' IDENTIFIED BY 'pass';

権限を与える。


GRANT ALL PRIVILEGES ON mydb.* TO 'user0'@'localhost';

phpでテスト。

<?php
    $db = new PDO("mysql:host=localhost;dbname=mydb;", 'user0', 'pass');
    $sql = 'create table test(id INT(10) AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20), age INT(4), r_time DATETIME)';
    $res = $db->query($sql);
    print "ok\n";
?>

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0