mysql -h 192.175.242.89 -u root
mysql -u root mysql
テーブルがどの様なSQL文で作成されたか表示します。
mysql> show create table webdb1.rss; | Table | Create Table | rss | CREATE TABLE `rss` ( `id` int(10) unsigned NOT NULL auto_increment, `title` varchar(255) NOT NULL default '', `link` text, `date` datetime default '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
参考:
http://www.rfs.jp/sitebuilder/sql/04/07.html#SHOW%20CREATE%20TABLE
Fedora Core release 3 (Heidelberg) にインストールしました。とりあえず、
MySQL-Max-5.0.15-0.i386.rpm MySQL-server-5.0.15-0.i386.rpm MySQL-client-5.0.15-0.i386.rpm <- Linux上のクライアント mysql-administrator-1.1.4-win.msi <- Windowsのクライアントとして
で動いてるっぽいです。
rpmでインストールした場合、
/usr/share/mysql/my-medium.cnf
などにあるみたいです。
webdb1というデータベースに接続可能なhogeというユーザ(パスワードはfuga)を追加する
mysql> grant all privileges on webdb1.* to hoge identified by 'fuga'; Query OK, 0 rows affected (0.00 sec)
このユーザはリモートからも接続可能です。
>mysql -u root mysql mysql> use mysql; Database changed mysql> select * from user; +-------------+------+----------+-------------+-------------+--------------+------------+ 〜 | Host | User | Password | Select_priv | Insert_priv | Update_priv | Grant_priv | 〜 +-------------+------+----------+-------------+-------------+--------------+------------+ 〜 | localhost | root | | Y | Y | Y | Y | 〜 | ctkyos18121 | root | | Y | Y | Y | Y | 〜 | localhost | | | N | N | N | N | 〜 | ctkyos18121 | | | N | N | N | N | 〜 +-------------+------+----------+-------------+-------------+--------------+------------+ 〜 4 rows in set (0.01 sec) mysql>
デフォルトでは、MySQLは外部からの接続を許可していません。あるユーザ(xxx)が外部から接続可能にする為には以下のようにします。
$ mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 to server version: 5.0.15-max Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> Use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> SELECT Host, User, Select_priv, Insert_priv,Update_priv, Delete_priv FROM user; +--------------+------+-------------+-------------+-------------+-------------+ | Host | User | Select_priv | Insert_priv | Update_priv | Delete_priv | +--------------+------+-------------+-------------+-------------+-------------+ | localhost | root | Y | Y | Y | Y | | localhost | | N | N | N | N | +--------------+------+-------------+-------------+-------------+-------------+ 4 rows in set (0.00 sec) mysql> grant all on *.* to xxx identified by 'hogehoge'; Query OK, 0 rows affected (0.02 sec) mysql> set password for xxx = password('hogehoge'); Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
mysqladmin variable
mysql -u xxxx -h xxx.xxx.xxx.xxx -p --default-character-set=ujis
など
DB Magazine 2004/12を読んだのですが、あらかじめ設定されているユーザ情報があると混乱するので、まずは消してからrootなどを新規作成した方がすっきりするとのこと。こんな感じでやってみました。
# mysql -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 19 to server version: 5.0.15-standard mysql> truncate table mysql.user; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> select * from mysql.user; Empty set (0.00 sec) mysql> grant all privileges on *.* to 'root'@'localhost' identified by 'hogehoge' with grant option; Query OK, 0 rows affected (0.00 sec)
grantする前にログアウトしちゃうと、入れなくなっちゃうので注意!
現在のアクセス:19529