:: กลับหน้าแรก :: แสดงเนื้อหาทั้งหมด ::
5.90 การเพิ่มผู้ใช้ใน Mysql: การเพิ่มผู้ใช้ จะทำให้ Databases ที่สร้างขึ้นมีความเป็นส่วนตัว
ในอันที่จริง ถ้าท่านเป็นเจ้าของระบบ และมี user เดียว หรือกำหนดสิทธิให้ทุกคนสามารถเข้าใช้ mysql ได้หมด ก็ไม่จำเป็นต้อง
สร้าง user ใน mysql เพราะท่านสามารถสร้าง table ใน test database และใช้งานได้เลย แต่ถ้าสร้าง user ขึ้นมา ทุกคนที่จะใช้ database
จะต้องมี user และ password ที่ถูกต้อง แต่ถ้าสร้างใน test ใคร ๆ ที่เข้าระบบได้ก็จะเข้าส่วนของ mysql ได้ .. ก็พิจารณาตามกรณีไป
สำหรับใน server นี้จะให้ทุกคนเข้าใช้ mysql ได้เต็มที่ .. และขอให้เป็นไปตามความเหมาะสม
หากไม่กำหนด user ก็สามารถใช้งานได้บางประการ แต่อาจไม่ทั้งหมด เมื่อกำหนด user ได้แล้ว ก็สามารถใช้งานตามขอบเขตของ database ที่กำหนดได้ แต่เรื่องที่สำคัญอีกประการหนึ่งก็คือ การกำหนดรหัสผ่านให้กับ root มิเช่นนั้น อาจมีคนเข้าไปกำหนด ซึ่งไม่เป็นการดีแน่ ซึ่งคำสั่งสำหรับกำหนดรหัสผ่านของ root ของ mysql คือ
/usr/bin/mysqladmin -u root password helloisinthai ควรทำเมื่อติดตั้ง Mysql เสร็จสิ้นตามขั้นตอน 5.1
ข้อมูลเกี่ยวกับการเพิ่มผู้ใช้
http://www.mysql.com/doc/A/d/Adding_users.html
MySQL root user, and the root user must have the insert privilege for the
mysql database and the reload administrative privilege. Also, if you have
changed the root user password, you must specify it for the mysql commands
below.
You can add new users by issuing GRANT statements:
shell> mysql --user=root -phelloisinthai
mysql> GRANT ALL PRIVILEGES ON *.* TO monty@localhost
IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO monty@"%"
IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT RELOAD,PROCESS ON *.* TO admin@localhost;
mysql> GRANT USAGE ON *.* TO dummy@localhost;
These GRANT statements set up three new users:
monty
A full superuser who can connect to the server from anywhere, but who must
use a password 'some_pass' to do so. Note that we must issue GRANT
statements for both monty@localhost and monty@"%". If we don't add the
entry with localhost, the anonymous user entry for localhost that is
created by mysql_install_db will take precedence when we connect from the
local host, because it has a more specific Host field value and thus comes
earlier in the user table sort order.
admin
A user who can connect from localhost without a password and who is
granted the reload and process administrative privileges. This allows the
user to execute the mysqladmin reload, mysqladmin refresh, and mysqladmin
flush-* commands, as well as mysqladmin processlist . No database-related
privileges are granted. (They can be granted later by issuing additional
GRANT statements.)
dummy
A user who can connect without a password, but only from the local
host. The global privileges are all set to 'N' -- the USAGE privilege type
allows you to create a user with no privileges. It is assumed that you
will grant database-specific privileges later.
|