Answer the question
In order to leave comments, you need to log in
Mysql in the console starts up through root with any password. How to fix?
Hello.
mysql 5.7.29
Password set to root.
Privileges:
mysql> SHOW GRANTS FOR 'root'@'localhost';
+---------------------------------------------------------------------+
| Grants for [email protected] |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> SHOW GRANTS FOR 'root'@'%';
+-------------------------------------------------------------+
| Grants for [email protected]% |
+-------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION |
+-------------------------------------------------------------+
1 row in set (0.00 sec)
mysql --host=localhost --user=root --password=qwe1
mysql --host=localhost --user=root -p
<?php
$link = mysqli_connect("localhost", "root", "");
if (!$link) {
echo "Ошибка: Невозможно установить соединение с MySQL." . PHP_EOL;
echo "Код ошибки errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Текст ошибки error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
$query = mysqli_query($link, "show databases;");
if(mysqli_num_rows($query) > 0)
{
$data = mysqli_fetch_assoc($query);
print_r($data);
}
else {
echo "empty";
}
php sql.php
Array
(
[Database] => information_schema
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question