注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

天高云淡的博客

A bad beginning makes a bad ending.

 
 
 

日志

 
 

Mysql user creation – setting up a MySQL new user account  

2009-12-27 19:16:33|  分类: php + mysql + ap |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

Mysql user creation – setting up a MySQL new user account

When you try to access MySQL database server from client such as mysql or even programming language such as php or perl you need a user account. MySQL has sophisticated user management system that controls who can access server and from which client system. It uses special tables in mysql database. In order to create a new user account you need a MySQL root account password.

Next you need to use the GRANT SQL command to set up the MySQL user account.

Finally, use the account's name and password to make connections to the MySQL server.

Please note that MySQL user accounts are different from UNIX/Linux login accounts. For example, the MySQL root user and the Linux/Unix root user are separate and have nothing to do with each other, even though the username is the same in each case.

Procedure for setting up a MySQL user account

Login in as mysql root user (at shell prompt type following command:):

$ mysql -u root -p

OR

$ mysql -u root -h myserver-sever.com -p

Create a new mysql database called demo

mysql> CREATE DATABASE demo;

Create a new user called user1 for database demo

mysql> GRANT ALL ON demo.* TO user1@localhost IDENTIFIED BY 'mypassword';

Note: GRANT ALL means all privileges i.e. user is permitted do anything. She can read, modify or delete data, but only on tables in the demo database. She cannot access any other database.

How do I connect to MySQL server using user1 account?

User user1 can connect to mysql server demo database using following command:

$ mysql -u user1 -p demo

OR

$ mysql -u user1 -h mysql.server.com -p demo

Where,

  • -u user1: MySQL Username
  • -h : MySQL server name (default is localhost)
  • -p : Prompt for password
  • demo: demo is name of mysql database (optional)
  评论这张
 
阅读(740)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017