You are not logged in.
>>> import mysql.connector as con
>>> my = con.connect(host="localhost",user="rnv",passwd="rnv",database="arnv")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.12/site-packages/mysql/connector/pooling.py", line 323, in connect
return MySQLConnection(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/mysql/connector/connection.py", line 179, in __init__
self.connect(**kwargs)
File "/usr/lib/python3.12/site-packages/mysql/connector/abstracts.py", line 1438, in connect
self._post_connection()
File "/usr/lib/python3.12/site-packages/mysql/connector/abstracts.py", line 1378, in _post_connection
self.set_charset_collation(charset=self._charset_id)
File "/usr/lib/python3.12/site-packages/mysql/connector/abstracts.py", line 1353, in set_charset_collation
self._execute_query(f"SET NAMES '{charset_name}' COLLATE '{collation_name}'")
File "/usr/lib/python3.12/site-packages/mysql/connector/connection.py", line 1333, in _execute_query
self.cmd_query(query)
File "/usr/lib/python3.12/site-packages/mysql/connector/opentelemetry/context_propagation.py", line 97, in wrapper
return method(cnx, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/mysql/connector/connection.py", line 872, in cmd_query
result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/mysql/connector/connection.py", line 648, in _handle_result
raise get_exception(packet)
mysql.connector.errors.DatabaseError: 1273 (HY000): Unknown collation: 'utf8mb4_0900_ai_ci'
>>>
Last edited by rnv_02 (2024-11-10 06:50:36)
Offline
Offline
well i tried looking into them but it seems like theres no dump file to be found with the first one and the second one doesnt have any sort of help to me.
after using reddit solution i get this
Traceback (most recent call last):
File "/home/aarnav/test.py", line 2, in <module>
students= pol.connect(
^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/mysql/connector/pooling.py", line 323, in connect
return MySQLConnection(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/mysql/connector/connection.py", line 179, in __init__
self.connect(**kwargs)
File "/usr/lib/python3.12/site-packages/mysql/connector/abstracts.py", line 1426, in connect
self._open_connection()
File "/usr/lib/python3.12/site-packages/mysql/connector/connection.py", line 373, in _open_connection
self._do_handshake()
File "/usr/lib/python3.12/site-packages/mysql/connector/connection.py", line 210, in _do_handshake
raise get_exception(packet)
mysql.connector.errors.DatabaseError: 1130: Host 'archnav' is not allowed to connect to this MariaDB server
Last edited by rnv_02 (2024-11-07 16:59:32)
Offline
mysql.connector.errors.DatabaseError: 1130: Host 'archnav' is not allowed to connect to this MariaDB server
Is that accurate that the server has not been configured to allow the host archnav to connect? Please use code tags for commands and their outputs e.t.c..
Edit:
Can you from same client connect to that server using `mysql`?
Last edited by loqs (2024-11-07 17:20:05)
Offline
mysql.connector.errors.DatabaseError: 1130: Host 'archnav' is not allowed to connect to this MariaDB server
Is that accurate that the server has not been configured to allow the host archnav to connect? Please use code tags for commands and their outputs e.t.c..
Edit:
Can you from same client connect to that server using `mysql`?
Yes I'm able to connect to that server using mysql
Offline
Try specifying a different collation in your connection, like `utf8mb4_general_ci`. You can add it in the `connect` function like this:
```python
my = con.connect(
host="localhost",
user="rnv",
passwd="rnv",
database="arnv",
charset="utf8mb4",
collation="utf8mb4_general_ci"
)
```
Offline
Try specifying a different collation in your connection, like `utf8mb4_general_ci`. You can add it in the `connect` function like this:
```python
my = con.connect(
host="localhost",
user="rnv",
passwd="rnv",
database="arnv",
charset="utf8mb4",
collation="utf8mb4_general_ci"
)
```
after making the changes i get
Traceback (most recent call last):
File "/home/aarnav/test.py", line 2, in <module>
students= pol.connect(
^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/mysql/connector/pooling.py", line 323, in connect
return MySQLConnection(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/mysql/connector/connection.py", line 179, in __init__
self.connect(**kwargs)
File "/usr/lib/python3.12/site-packages/mysql/connector/abstracts.py", line 1426, in connect
self._open_connection()
File "/usr/lib/python3.12/site-packages/mysql/connector/connection.py", line 373, in _open_connection
self._do_handshake()
File "/usr/lib/python3.12/site-packages/mysql/connector/connection.py", line 210, in _do_handshake
raise get_exception(packet)
mysql.connector.errors.DatabaseError: 1130: Host 'archnav' is not allowed to connect to this MariaDB server
i am able to connect to my host by using mysql
Offline
I was able to solve this problem that is by making a python virtual env,
Solution steps
mkdir dirforenv
~/dirforenv/bin/pip install mysql.connector
source ~/dirforenv/bin/activate
and then run the python script, it should work now
Offline
You worked around the issue by switching to the deprecated https://pypi.org/project/mysql-connector/? If there is an issue with mysql-connector-python perhaps you should report it upstream?
Offline