Home > 備忘録 > MySQL に関すること > データベースへ接続( 93 )
[root@server]# mysql -u root -p ←root権限でログイン
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 888
Server version: 5.5.20 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ←MySQLにログインできた状態mysql> exit
Bye
[root@server]# ←ログアウトできた状態mysql> quit
Bye
[root@server]# ←ログアウトで1きた状態mysql> grant all privileges on demo.* to fedora@localhost identified by 'kokohorewanwan'; ←demoデータベースへの全てのアクセス権限を持った、パスワード'kokohorewanwan'をもった新規ユーザーfedoraを登録
mysql>mysql> select user,host,password from mysql.user;
+--------+-------------+-------------------------------------------+
| user | host | password |
+--------+-------------+-------------------------------------------+
| root | localhost | ***************************************** |
| root | leom.mydns.jp | ***************************************** |
| root | 127.0.0.1 | ***************************************** |
| root | ::1 | ***************************************** |
| fedora | localhost | ***************************************** |
+--------+-------------+-------------------------------------------+
5 rows in set (0.34 sec)
mysql>mysql> delete from mysql.user where user='fedora';
Query OK, 1 rows affected (0.00 sec)
mysql>mysql> create database demo;
Query OK, 1 row affected (0.00 sec)
mysql> show databases; ←作成の確認
+--------------------+
| Database |
+--------------------+
| information_schema |
| demo |
+--------------------+
2 rows in set (0.00 sec)
mysql>mysql> drop database demo;
Query OK, 1 row affected (0.00 sec)
mysql> show databases; ←削除の確認
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
1 rows in set (0.00 sec)
mysql>