小编Pra*_*ngh的帖子

django.db.utils.operationalError: (2059,"身份验证插件'caching_sha2_password'")

我正在尝试将我的 django 项目“mysite”连接到 mysql。我在 mysql 中创建了一个用户并授予它访问该项目的所有权限。这些是我对 settings.py 所做的更改:

    DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.mysql',
    'NAME': 'mysitedb',
    'USER': 'username',
    'PASSWORD': 'password',
    'HOST': 'localhost',
    'PORT': '',
}
}
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试使用 迁移数据库时python3 manage.py makemigrations,出现以下错误:

django.db.utils.OperationalError: (2059, "Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory")</code></pre>
Run Code Online (Sandbox Code Playgroud)

完整的堆栈跟踪如下:

Traceback (most recent call last):
File "/home/prabhjeet/.local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/home/prabhjeet/.local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/prabhjeet/.local/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 236, in get_new_connection …
Run Code Online (Sandbox Code Playgroud)

python mysql django mysql-python python-3.x

6
推荐指数
2
解决办法
1万
查看次数

如何在train_test_split中选择RandomState?

我了解如何使用随机状态将数据随机分成训练集和测试集。正如预期的那样,我的算法每次更改时都会给出不同的准确度。现在我必须在我的大学提交一份报告,我无法理解在那里提到的最终准确性。我应该选择我得到的最大精度吗?或者我应该用不同的 RandomStates 运行它,然后取其平均值?或者是其他东西?

python machine-learning svm pandas scikit-learn

5
推荐指数
1
解决办法
4210
查看次数

Django内置登录系统-找不到帐户/个人资料/

我正在为我的网站使用django内置登录系统。每当我创建一个帐户并尝试登录时,它都会重定向到该页面http://127.0.0.1:8000/accounts/profile/并显示未找到的错误页面。

但是,当我手动accounts/profile/从url中删除该部分时,它将登录到网站。如何使django系统直接重定向到http://127.0.0.1:8000而不是上述URL。

这是我的urls.py文件代码:

urlpatterns = [   
    path('',include('feedback.urls')),
    path('accounts/', include('django.contrib.auth.urls')),
    path('admin/', admin.site.urls),
    path('login/', auth_views.login, {'template_name': 'login.html'}, name='login'),
    path('logout/', auth_views.logout, {'next_page': 'login'}, name='logout'),
    path('signup/', core_views.signup, name='signup'),
Run Code Online (Sandbox Code Playgroud)

]

反馈/urls.py:

urlpatterns = [
    path('create_url/',views.create_url,name='create_url'),
    path('submit_affective/',views.submit_affective,name='submit_affective'),
    path('submit_cognitive/',views.submit_cognitive,name='submit_cognitive'),
    path('thanks/',views.thanks,name='thanks'),
    path('detail_affective/<int:id>',views.detail_affective,name='detail_affective'),
    path('detail_cognitive/<int:id>',views.detail_cognitive,name='detail_cognitive'),
    path('',views.index,name='index'),
Run Code Online (Sandbox Code Playgroud)

]

python django login django-forms

1
推荐指数
1
解决办法
1448
查看次数

javax.crypto.BadPaddingException:给定最终块在解密时未正确填充

我试图解密java中的文件.解密文件的前16个字节是IV(初始化向量).请帮助解决上述异常.

我试图在AESFileEncryption()中的输出文件中添加IV,然后在解密时读取它.

谢谢.

public class AESFileEncryption {
public static void encrypt(String path,String pwd) throws Exception {

    FileOutputStream outFile;

    try ( 
            FileInputStream inFile = new FileInputStream(path)) {

        String fileName=path;

        System.out.println(path);

        outFile = new FileOutputStream(fileName+".aes");
        // password to encrypt the file
        String password = pwd;
        byte[] salt = {
        (byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c,
        (byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99
       };

        SecretKeyFactory factory = SecretKeyFactory
                .getInstance("PBKDF2WithHmacSHA1");
        KeySpec keySpec = new PBEKeySpec(password.toCharArray(),salt,65536,128);// user-chosen password that can be used with password-based encryption (PBE).
        SecretKey secretKey = factory.generateSecret(keySpec); …
Run Code Online (Sandbox Code Playgroud)

java encryption cryptography exception aes

0
推荐指数
1
解决办法
67
查看次数