Форум русскоязычного сообщества Ubuntu


Увидели сообщение с непонятной ссылкой, спам, непристойность или оскорбление?
Воспользуйтесь ссылкой «Сообщить модератору» рядом с сообщением!

Автор Тема: PowerShell + MySQL  (Прочитано 10505 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн exonix

  • Автор темы
  • Любитель
  • *
  • Сообщений: 80
    • Просмотр профиля
PowerShell + MySQL
« : 17 Мая 2013, 17:49:41 »
Доброго дня. Хочу из винды из PowerShell подключаться к базе MySQL.
Есть два сервера. Один:
Цитировать
root@doc:~# uname -a
Linux doc 2.6.32-5-amd64 #1 SMP Sun May 6 04:00:17 UTC 2012 x86_64 GNU/Linux
root@doc:~# mysql -V
mysql Ver 14.14 Distrib 5.1.63, for debian-linux-gnu (x86_64) using readline 6.1
назначил там:
Цитировать
CREATE USER 'root'@'192.168.10.10' IDENTIFIED BY '***';
GRANT ALL PRIVILEGES ON * . * TO 'root'@'192.168.10.10' IDENTIFIED BY '***' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
и подключение есть. А вот второй сервер:
Цитировать
root@debian7:~# uname -a
Linux debian7 3.2.0-4-amd64 #1 SMP Debian 3.2.41-2 x86_64 GNU/Linux
root@debian7:~# mysql -V
mysql Ver 14.14 Distrib 5.5.31, for debian-linux-gnu (x86_64) using readline 6.2
Дал такие же права, а подключится не могу. Вот скрипт подключения, и ошибка:
Цитировать
Add-Type -Path "C:\Program Files (x86)\MySQL\MySQL Connector Net 6.6.5\Assemblies\v4.0\MySql.Data.dll"
$connectionString = "server=debian7;uid=root;pwd=1q2w#E$R;database=inv;"
$connection = New-Object MySql.Data.MySqlClient.MySqlConnection
$connection.ConnectionString = $connectionString
$connection.Open()

and got error message:
Exception calling "Open" with "0" argument(s): "Authentication to host '192.168.10.174' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user
'root'@'pc11.domain.local' (using password: YES)"
At line:5 char:1
+ $connection.Open()
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : MySqlException
почему-то подставляется имя моего компьютера... И не могу найти, как указать, чтобы проверка была по внутренним пользователям.
Помогите, пожалуйста. Спасибо.

Оффлайн victor00000

  • Старожил
  • *
  • Сообщений: 15568
  • Глухонемой (Deaf)
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #1 : 17 Мая 2013, 19:04:36 »
cat /etc/mysql/my.cnf | grep bind?
Wars ~.o

Оффлайн exonix

  • Автор темы
  • Любитель
  • *
  • Сообщений: 80
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #2 : 17 Мая 2013, 19:16:49 »
Цитировать
root@debian7:~# cat /etc/mysql/my.cnf | grep bind
bind-address            = 192.168.10.174
на рабочем тоже указывает на себя:
Цитировать
root@doc:~#  cat /etc/mysql/my.cnf | grep bind
bind-address            = 192.168.10.20

Оффлайн victor00000

  • Старожил
  • *
  • Сообщений: 15568
  • Глухонемой (Deaf)
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #3 : 17 Мая 2013, 19:27:20 »
Цитировать
CREATE USER 'root'@'192.168.10.10' IDENTIFIED BY '***';
CREATE USER 'root'@'%' IDENTIFIED BY '***';
Wars ~.o

Оффлайн exonix

  • Автор темы
  • Любитель
  • *
  • Сообщений: 80
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #4 : 17 Мая 2013, 20:19:07 »
#1396 - Operation CREATE USER failed for 'root'@'%'наверное от того, что уже делал это.

сейчас права выглядят так на нерабочем сервере: (я удалил сейчас для отдельного хоста)


а вот так на рабочем сервере:

« Последнее редактирование: 22 Января 2014, 21:18:16 от exonix »

Оффлайн victor00000

  • Старожил
  • *
  • Сообщений: 15568
  • Глухонемой (Deaf)
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #5 : 17 Мая 2013, 21:13:00 »
root@victor0000:~#
root@victor0000:~# mysql -uroot -p1 -h192.168.100.2
ERROR 1045 (28000): Access denied for user 'root'@'192.168.100.2' (using password: YES)
root@victor0000:~# mysql -uroot -p1
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 50
Server version: 5.1.67-0ubuntu0.10.04.1 (Ubuntu)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE USER 'root'@'%' IDENTIFIED BY '2';
Query OK, 0 rows affected (0.00 sec)

mysql> \q
Bye
root@victor0000:~# mysql -uroot -p1 -h192.168.100.2
ERROR 1045 (28000): Access denied for user 'root'@'192.168.100.2' (using password: YES)
root@victor0000:~# mysql -uroot -p2 -h192.168.100.2
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 52
Server version: 5.1.67-0ubuntu0.10.04.1 (Ubuntu)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> DROP USER root;
ERROR 1227 (42000): Access denied; you need the CREATE USER privilege for this operation
mysql> \q
Bye
root@victor0000:~# mysql -uroot -p1
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 53
Server version: 5.1.67-0ubuntu0.10.04.1 (Ubuntu)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> DROP USER root;
Query OK, 0 rows affected (0.00 sec)

mysql> \q
Bye
root@victor0000:~# mysql -uroot -p2 -h192.168.100.2
ERROR 1045 (28000): Access denied for user 'root'@'192.168.100.2' (using password: YES)
root@victor0000:~#
Wars ~.o

Оффлайн exonix

  • Автор темы
  • Любитель
  • *
  • Сообщений: 80
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #6 : 17 Мая 2013, 21:20:32 »
Цитировать
root@debian7:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 57
Server version: 5.5.31-0+wheezy1 (Debian)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE USER 'root'@'%' IDENTIFIED BY '2';
ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'%'
если его удалить в phpmyadmin то можно добавить:
Цитировать
mysql> CREATE USER 'root'@'%' IDENTIFIED BY '2';
Query OK, 0 rows affected (0.00 sec)
всё равно такая же ошибка. у меня вот какое сомнение, если на рабочий сервер сделать:
Цитировать
telnet doc 3306
?
 5.1.63-0+squeeze1Ў╡☻@MDN:xl☻j4`imhAM=*Ya
а вот если сделать на нерабочий сервер:
Цитировать
telnet denian7 3306
T
 5.5.31-0+wheezy1Х?bSV8T|☻А§3=yj),?:C$&3mysql_native_password
что такое mysql_native_password ?

Оффлайн victor00000

  • Старожил
  • *
  • Сообщений: 15568
  • Глухонемой (Deaf)
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #7 : 17 Мая 2013, 21:26:47 »
root@victor0000:~# mysql -uroot -p1
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 53
Server version: 5.1.67-0ubuntu0.10.04.1 (Ubuntu)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> DROP USER root;
Query OK, 0 rows affected (0.00 sec)

mysql> \q
внимание пост, начало удалить drop роот, потом далше create user root...
Wars ~.o

Оффлайн exonix

  • Автор темы
  • Любитель
  • *
  • Сообщений: 80
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #8 : 17 Мая 2013, 21:40:35 »
удалил, создал - тоже самое:
Цитировать
Exception calling "Open" with "0" argument(s): "Authentication to host '192.168.10.174' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user
'root'@'pc11.domain.local' (using password: YES)"
почему он спрашивает про 'root'@'pc11.domain.local' ?

и ещё я вхожу так:
Цитировать
root@debian7:~# mysql -uroot -p1
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
root@debian7:~# mysql -uroot -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Оффлайн victor00000

  • Старожил
  • *
  • Сообщений: 15568
  • Глухонемой (Deaf)
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #9 : 17 Мая 2013, 21:48:07 »
mysql -uroot -h192.168.10.174 -pработает?
Wars ~.o

Оффлайн exonix

  • Автор темы
  • Любитель
  • *
  • Сообщений: 80
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #10 : 17 Мая 2013, 21:55:41 »
нет.
Цитировать
root@debian7:~# mysql -uroot -h 192.168.10.174 -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'debian7' (using password: YES)
localhost - да
Цитировать
root@debian7:~# mysql -uroot -h localhost -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 166
debian7 - нет
Цитировать
root@debian7:~# mysql -uroot -h debian7 -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'debian7' (using password: YES)

Оффлайн victor00000

  • Старожил
  • *
  • Сообщений: 15568
  • Глухонемой (Deaf)
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #11 : 17 Мая 2013, 21:57:27 »
неправильно пароль и забыл?!


Пользователь решил продолжить мысль 17 Мая 2013, 21:59:32:
Цитировать
Enter password:
точно ответ пароль работает.
« Последнее редактирование: 17 Мая 2013, 21:59:32 от victor00000 »
Wars ~.o

Оффлайн exonix

  • Автор темы
  • Любитель
  • *
  • Сообщений: 80
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #12 : 17 Мая 2013, 22:01:48 »
copy-paste 1q2w#E$R - не пускает с правильным паролем.

Оффлайн victor00000

  • Старожил
  • *
  • Сообщений: 15568
  • Глухонемой (Deaf)
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #13 : 17 Мая 2013, 22:02:09 »
debian7 ?
cat /etc/hosts?
Wars ~.o

Оффлайн exonix

  • Автор темы
  • Любитель
  • *
  • Сообщений: 80
    • Просмотр профиля
Re: PowerShell + MySQL
« Ответ #14 : 17 Мая 2013, 22:04:00 »
Цитировать
root@debian7:~# cat /etc/hosts
127.0.0.1       localhost
127.0.1.1       debian7.domain.local debian7
192.168.10.174  debian7 debian7.domain.local

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

 

Страница сгенерирована за 0.054 секунд. Запросов: 25.