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用戶的狀態

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM