当前位置:   article > 正文

在ubuntu18中安装mysql8.0、配置及使用_ubuntu18安装mysql8.0.30

ubuntu18安装mysql8.0.30

主要内容

适用范围

本教程主要用于ubuntu18中安装mysql8.0

一、安装mysql

  1. wget https://dev.mysql.com/get/mysql-apt-config_0.8.14-1_all.deb
  2. dpkg -i mysql-apt-config_0.8.14-1_all.deb
  3. sudo apt-get update
  4. sudo apt-get install mysql-server

二、安装mysqlclient

(1) 安装依赖包

  1. libmysqlclient-dev
  2. python3.X-dev
  3. openssl
  4. libssl-dev
    (2)安装libmysqlclient-dev
  5. wget https://dev.mysql.com/get/Downloads/MySQL-8.0/libmysqlclient21_8.0.18-1ubuntu18.04_amd64.deb
  6. dpkg -i libmysqlclient21_8.0.18-1ubuntu18.04_amd64.deb
  7. sudo apt-get update
  8. sudo apt-get install libmysqlclient-dev
    (3)安装python3.X、openssl、libssl-dev
  9. sudo apt-get install python3.X-dev openssl libssl-dev
    (4) 安装mysqlclient
    sudo pip install mysqlclient
    注:mysqlclient用于连结python与数据库mysql

三、配置django2中的setting

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mydatabase',
        'USER': 'mydatabaseuser',
        'PASSWORD': 'mypassword',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

注:修改: ‘HOST’: ‘localhost’, ‘PORT’: ‘3306’,

四、 创建用户、修改密码及用户权限

  1. 创建用户
create user 'username'@'localhost' identified by 'new password'
  • 1
  1. 修改密码
#对mysql8.0以下使用的
alter user 'username'@'localhost' identified by 'new password'
#对mysql8.0.26使用以下代码,不然会出错
#因为mysql8.0.26默认是caching_sha2_password,要修改成mysql_native_password
create user 'user_name'@'localhost' identified with mysql_native_password by 'newpassword';
#如果已经创建好的,修改方式如下
alter user 'user_name'@'localhost' identified with mysql_native_password by 'newpassword';
#查看编码方式
use mysql;
select user,plugin from user where user='schoolAdminSystem_db';
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  1. 用户权限
grant all privileges on database_name.* to username@localhost;
flush privileges;
  • 1
  • 2
  1. 创建数据库
create database database_name default charset=utf8 default collate utf8_unicode_ci;
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/494992
推荐阅读
相关标签
  

闽ICP备14008679号