Вторник, 23.04.2024, 17:42
Приветствую Вас Гость | RSS
Мой сайт
Главная
Регистрация
Вход
Форма входа

Меню сайта

Категории раздела
Об ОС Windows [137]
В категории размещаются статьи, касающщиеся операционных систем от Microsoft.
Об ОС *Nix [198]
В данной категории собраны статьи об ОС семейства Unix/Linux/FreeBSD/...
Справочные материалы [351]
Справка по всему разделу.
Виртуализация и Облака [46]
Networks & Routing [86]
DataBases [22]

Наш опрос
Оцените мой сайт
Всего ответов: 209

Статистика

Онлайн всего: 1
Гостей: 1
Пользователей: 0

Главная » Статьи » Системное администрирование » Об ОС *Nix

доступ в базу MySQL с другого компа
Выполните команду:
GRANT ALL PRIVILEGES ON `имя_базы`.* TO myuser@% IDENTIFIED BY 'пароль';

Step 1 - Create new MySQL user


MySQL create user

Nowadays security is more and more important even in case of smaller websites. As a lot of site uses some database so this is one point where we can make some improvements.

In this article we will work with MySQL on our goal is to create a new user in the database.

There are more ways how you can do this.

  • Using CREATE USER and/or GRANT commands
  • Inserting a new record into the mysql.user table

First let's see how to use the CREATE USER command. Here I have to mention that thi s command is available only in MySQL 5 (5.0.2) and newer releases. The syntax is the following:   

 CREATE USER user [IDENTIFIED BY [PASSWORD] 'password']

Here is an example:

Code:
  1.  
  2. CREATE USER 'user1'@'localhost' IDENTIFIED BY 'pass1';
  3.  

Now if you check the mysql.user table you can find a new record in it. Notice that all priviliges are set to No so this user can do nothing in the DB. To add some preiviliges we can use the GRANT command as follows:

Code:
  1.  
  2. GRANT SELECT,INSERT,UPDATE,DELETE ON *.* TO 'user1'@'localhost';
  3.  

Here we have added only the most important priviliges to the user. With the setting above this user is good to run a CMS or a blog, however with such settings this user is not able to install them as it can not create tables. 

To add all priviliges to the user you don't have to list all of them but you can use the ALL shortcut as follows:

Code:
  1.  
  2. GRANT ALL ON *.* TO 'user1'@'localhost';
  3.  

You can create a new MySQL user in one step as well using again the GRANT command with a small extension as here:

Code:
  1.  
  2. GRANT ALL ON *.* TO 'user2'@'localhost' IDENTIFIED BY 'pass1';
  3.  

The above examples used dedicated commands, but sumtimes you maybe want to add a new MySQL user via directly editing the mysql.user table. In this case you just inserts a new record into the table with a normal INSERT command:

Code:
  1.  
  2. INSERT INTO user (Host,User,Password)
  3. VALUES('localhost','user3',PASSWORD('pass3'));
  4.  

Or you can add some priviliges as well in a form like this:

Code:
  1.  
  2. INSERT INTO user (Host,User,Password,Select_priv,Insert_priv)
  3. VALUES('localhost','user4',PASSWORD('pass3'),'Y','Y');
  4.  

That's it!




Источник: http://sqlinfo.ru/forum/viewtopic.php?id=907 http://www.databasef1.com/tutorial/mysql-create-user.html
Категория: Об ОС *Nix | Добавил: admin (22.06.2010)
Просмотров: 1269 | Рейтинг: 0.0/0
Всего комментариев: 0
Имя *:
Email *:
Код *:
Поиск

Друзья сайта
  • Официальный блог
  • Сообщество uCoz
  • FAQ по системе
  • Инструкции для uCoz


  • Copyright MyCorp © 2024