2008年9月23日 星期二

MySQL

安裝 apt-get install mysql-server
啟動 /etc/init.d/mysql start
#mysql-server
>show databases;
>create database fcu; // fcu是使用者自己建立的資料庫名稱
>drop database fcu; // 刪除fcu使用者自己建立的資料
>exit

client端到MySQL-Server
.本機 #mysql -u root -p
.遠端 #mysql -h 140.134.210.131 -u root -p


資料庫操作
1.在本機以client程式連線
#mysql -u root -p
2.進入後以指令查詢
>show databases;
>create database fcu; // fcu是使用者自己建立的資料庫名稱
>show databases;
3.建立管理者(root)遠端連線帳號 -->root對所有的資料庫都有管理權限
>GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED By "something" WITH GRANT OPTION;
4.設定密碼
>set password for root@"%"=password("1234");
>set password for root@"localhost"=password("1234");
5.離開
>exit
6.修改 /etc/mysql/my.cnf
將 bind-address 127.0.0.1 註解
7.重新啟動 mysql
#/etc/init.d/mysql restart

------------------------------------------------
以上設定針對root
若要以user來做管理資料庫
#mysql -u root -p
>create database 資料庫名稱;
>grant all privileges on 資料庫名稱.* to UserName@"%" identified By "密碼xxxxx";
>exit
#/etc/init.d/mysql restart

沒有留言: