[转]mysql8.0.21在ubuntu20.04下的配置问题

一、安装命令

sudo apt install mysql-server
# 查看mysql安装状态
sudo service mysql status

二、配置文件的问题

1、配置文件的位置: /etc/mysql


debian.cnf: 保存着账号信息
my.cnf: 指出实际配置文件的位置:/etc/mysql/mysql.conf.d/

mysqld.cnf: 实际的配置信息

2、其他文件位置
/usr/bin                 客户端程序和脚本  
/usr/sbin                mysqld 服务器  
/var/lib/mysql           日志文件,数据库  [重点要知道这个]  
/usr/share/doc/packages  文档  
/usr/include/mysql       包含( 头) 文件  
/usr/lib/mysql           库  
/usr/share/mysql         错误消息和字符集文件  
/usr/share/sql-bench     基准程序  

三、初始密码的问题

1、root用户的状态

mysql> select host,user from user;
        +-----------+------------------+
        | host      | user             |
        +-----------+------------------+
        | localhost | debian-sys-maint |
        | localhost | mysql.infoschema |
        | localhost | mysql.session    |
        | localhost | mysql.sys        |
        | localhost | root             |
        +-----------+------------------+
        5 rows in set (0.00 sec)
2、更改root用户的密码

在更改密码的同时,还修改user表中的plugin字段为‘mysql_native_password’,该字段的作用还不太明了,看官网说明,大概是密码的验证方式之类的。但不改这个直接修改密码好像还不成功。

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
3、新添加用户并授权
create user 'admin'@'%' identified by '123';
grant all on * to 'admin'@'%' with grant option;
alter user 'admin'@'%' identified with mysql_native_password by '456';

四、msyqlclient的安装问题

  • mysqlclient安装不成功主要缺少两个包:
sudo  apt-get install libmysqlclient-dev libpython3.8-dev
  • 如果还有错,那就把wheel装上:
pip install wheel

五、卸载的问题

Removing MySQL with APT

  • To uninstall the MySQL server and the related components that have been installed using the MySQL APT repository, first, remove the MySQL server using the following command:

shell> sudo apt-get remove mysql-server

  • Then, remove any other software that was installed automatically with the MySQL server:

shell> sudo apt-get autoremove

  • To uninstall other components, use the following command, replacing package-name with the name of the package of the component you want to remove:

shell> sudo apt-get remove package-name

  • To see a list of packages you have installed from the MySQL APT repository, use the following command:

shell> dpkg -l | grep mysql | grep ii

六、遇到的坑

mysql> show tables;
ERROR 1449 (HY000): The user specified as a definer ('mysql.infoschema'@'localhost') does not exist
mysql> show databases;
ERROR 1449 (HY000): The user specified as a definer ('mysql.infoschema'@'localhost') does not exist
  • 第一步,停止MySql服务
service mysql stop
  • 第二步,用mysqld对MySql的一些文件进行升级
sudo mysqld --upgrade=FORCE
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值