MySQL8在Ubuntu22.04.4环境下的笔记
一、安装
sudo apt update
sudo apt install mysql-server
sudo systemctl status mysql
二、卸载
sudo apt remove --purge mysql-*
sudo apt autoremovedpkg --list | grep mysql
查询是否还存在相关的依赖组件dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
如果还存在一些依赖,则继续用“apt remove 依赖包名称”命令删除;确认删除完整后,清理残余文件
sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql
二、配置root密码
sudo cat /etc/mysql/debian.cnf
[client]
host = localhost
user = debian-sys-maint
password = BT7UqYiANV3sePN2
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = BT7UqYiANV3sePN2
socket = /var/run/mysqld/mysqld.sock
mysql -u debian-sys-maint -p
修改root用户密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'zhengjun';
三、配置支持大小写
参考文献文章来源:https://www.toymoban.com/news/detail-855630.html
https://askubuntu.com/questions/1261422/how-to-install-mysql-8-0-with-lower-case-table-names-1-on-ubuntu-server-20-04-lt文章来源地址https://www.toymoban.com/news/detail-855630.html
通过在安装后使用新值重新初始化 MySQL
一、安装 MySQL:
sudo apt-get update
sudo apt-get install mysql-server -y
二、停止MySQL服务:
sudo service mysql stop
三、删除MySQL数据目录:
sudo rm -rf /var/lib/mysql
四、重新创建MySQL数据目录并配置权限:
sudo mkdir /var/lib/mysql
sudo chown mysql:mysql /var/lib/mysql
sudo chmod 700 /var/lib/mysql
五、添加到中的部分 /etc/mysql/mysql.conf.d/mysqld.cnf
lower_case_table_names = 1
[mysqld]
六、使用以下命令重新初始化 MySQL:
sudo mysqld --defaults-file=/etc/mysql/my.cnf --initialize --lower_case_table_names=1 --user=mysql --console
七、启动MySQL服务:
sudo service mysql start
八、检索MySQL用户新生成的密码:root
sudo grep 'temporary password' /var/log/mysql/error.log
九、更改MySQL用户的密码:
sudo mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPa$$w0rd';
十、验证设置:lower_case_table_names
sudo mysql -u root -p
执行:
SHOW VARIABLES LIKE 'lower_case_%';
预期输出:
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_file_system | OFF |
| lower_case_table_names | 1 |
+------------------------+-------+
到了这里,关于Ubuntu22.04.4 - MySQL8 - 笔记的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!