5
6月
2023
“如何重新安装MySQL Server?”
13:35

“如何重新安装MySQL Server?”

5 6月 2023 13:35

更新其版本时,需要重新安装MySQL服务器。

为什么更新mysql服务器

*主要区别,版本(8.0.33) - 您可以安装最新版本 ODBC连接器。 由于包装的依赖性没有问题。

MS SQL安装要求

为了满足这一指令,我们需要:

1)Linux
2)该计算机操作系统的根用户的密码,否则您必须位于此PC的Sudo,Sudoers或Wheels组中(请参阅组命令)。
3)MS SQL数据库管理系统中的root用户密码(但是您可以将其放置 - 请参见下一节)。
4)自由空间 - 数据库约0.5 GB。

如果MySQL中的根密码未知或忘记

以下步骤将有助于重置根密码:

1)停止MySQL

sudo service mysql stop

2)以安全的垄断模式启动mysql

sudo mkdir /var/run/mysqld
sudo chmod 1777 /var/run/mysqld;
sudo mysqld_safe --skip-grant-tables

或修复文件/etc/mysql/conf.d/mysql.cnf-delete a评论#在行#skip-grant-table之前
并重新启动sudo服务mysql启动服务

从另一个终端窗口

sudo mysql -u root

对于MySQL 8.0及以上,我们执行mySQL命令:

使用mysql; 更新用户集Authentication_string = Concat('\*',upper(sha1(sha1(sha1('11111'))))),其中用户='root'; 更新用户集插件=“ mysql_native_password”其中user ='root'; 冲洗特权; 退出 我们完成了第一个窗口(sudo mysqld_saf-grant-tables)团队运行 然后我们完成MySQLD流程: sudo pkill mysqld 服务发布: sudo service mysql start 考试: mysql -u root -p -h localhost `11111` ### 1)备份备份(备份DB) 官方的备份文档 [这里](https://dev.mysql.com/doc/refman/8.0/en/backup-and-recovery.html)。 找出数据库名称: mysql -u root -p -h localhost show databases; 我们将备份(数据导出)从数据库到文本文件: mysqldump -u root -p -h localhost primer > primer.sql mysqldump -u root -p -h localhost test > test.sql mysqldump -u root -p -h localhost db_1 > db_1.sql 该程序将向MySQL请求root密码。 输入密码11111(用于root)。 ### 2)删除以前的MySQL安装 删除MySQL客户端: sudo apt-get purge mysql-client mysql-client-8.0 mysql-client-core-8.0 备份数据库后,您可以删除MySQL Server [指示](https://learnubuntu.com/uninstall-mysql/) sudo apt purge mysql-server mysql-common* mysql-server-5.7* mysql-server-8.0* 删除配置 sudo rm -r /etc/mysql /var/lib/mysql /var/log/mysql 清除 sudo apt autoclean && sudo apt autoremove 删除服务器后,将显示一个窗口,并随着删除数据库的请求 - 您需要同意。 ### 3)根据“ APT”的说明安装新版本的MySQL Server的副本 官方安装说明mysql [这里](https://dev.mysql.com/doc/refman/8.0/en/linux-installation.html)。 我选择了Apt -uncession的选项 [这里](https://dev.mysql.com/doc/refman/8.0/en/linux-installation-apt-repo.html) 1)我们以DEB文件的形式加载存储库设置软件包(17 kb) - 它不依赖于平台 从页面 [https://dev.mysql.com/downloads/repo/apt/](https://dev.mysql.com/downloads/repo/apt/) 以双击打开DEB,例如执行命令。 dpkg -i mysql-apt-config_0.8.25-1_all.deb 启动时,将需要向您添加APT Config的OS请求。 Linux Mint 21.1 Vera对应于Ubuntu Jammy(22)。 对于其他操作系统,选择会有所不同。 我们回答问题(对于GDEBI或DPKG中的图形方法 - 类似)。 (按照图像增加图片)。 向“将存储库添加到支持的服务器”的问题 - 我们为我的OS版本(Ubuntu / Debian)做出选择 - 我有“ Ubuntu Jammy” ![Debi](debi.png?lightbox&classes=img-zoomable "debi") 在下一步中,我选择了“ MySQL工具和连接器” ![Debi2](debi2.png?lightbox&classes=img-zoomable "debi2") 在第三步,“启用或禁用MySQL工具和实用程序”选择“启用”,因为工作站用于开发。 ![Debi3](debi3.png?lightbox&classes=img-zoomable "debi3") 在最后一步,我选择了“确定”项目来确认正确的数据并完成包设置。 ![Debi4](debi4.png?lightbox&classes=img-zoomable "debi4") 我们更新系统中的存储库: sudo apt-get update 在更新期间,很明显,这些文件是从网站中获取的,“萝卜” http://repo.mysql.com/apt/ubuntu jammy inrelease 我继续实现 [MySQL安装说明](https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/) : #### MySQL社区服务器软件包团队,可选软件包和MySQL客户端插件的文件 服务器,可选的MySQL-Common包和MySQL-Community-Client-Plugins插件,最好由_odnoy command_设置。 sudo apt-get install mysql-server mysql-common mysql-community-client-plugins 我们设置了root密码(单击图片以增加): ![根](root.png?lightbox&classes=img-zoomable "root") 选择加密密码的所需方法(单击图片以增加图片): ![root2](root2.png?lightbox&classes=img-zoomable "root2") MySQL服务自动安装后开始。 检查她的工作: sudo systemctl status mysql 为了加强安全性,您可以禁止与MySQL Server的远程连接 sudo mysql_secure_installation `Securing the MySQL server deployment.` `Enter password for user root: ` `VALIDATE PASSWORD COMPONENT can be used to test passwords` ``and improve security. It checks the strength of password` `and allows the users to set only those passwords which are` `secure enough. Would you like to setup VALIDATE PASSWORD component?` `Press y|Y for Yes, any other key for No: n` `Using existing password for root.` `Change the password for root ? ((Press y|Y for Yes, any other key for No) : n` `... skipping.` `By default, a MySQL installation has an anonymous user,` `allowing anyone to log into MySQL without having to have` `a user account created for them. This is intended only for` `testing, and to make the installation go a bit smoother.` `You should remove them before moving into a production` `environment.` `Remove anonymous users? (Press y|Y for Yes, any other key for No) : n` `... skipping.` `Normally, root should only be allowed to connect from` `'localhost'. This ensures that someone cannot guess at` `the root password from the network.` `Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y` `Success.` `By default, MySQL comes with a database named 'test' that` `anyone can access. This is also intended only for testing,` `and should be removed before moving into a production` `environment.` `Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n` `... skipping.` `Reloading the privilege tables will ensure that all changes` `made so far will take effect immediately.` `Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y` `Success.` `All done! ` 我们检查了使用数据库“ root”用户名称的连接: mysql -u root -p и вводим пароль: 由于MySQL启动并有效,因此标准邀请 ** mysql> ** 将显示在终端中。 我们编写用于创建数据库的命令: 创建数据库引物; 使用底漆; 源引物.sql; 等每个数据库。 从客户Mysql退出的团队: quit CHECQL版本检查: mysql --version X86_64上的Linux的MySQL VER 8.0.33(MySQL社区服务器-GPL) ### MUSQL连接通过防火墙的许可 打开UFW sudo ufw enable 如果应该从外部连接到MySQL,我们允许访问MySQL到达服务器: sudo ufw allow mysql 如果不需要从外部的本地主机到MySQL的远程连接,我们禁止远程访问MySQL Server: sudo ufw deny mysql ### 结果 我们刚刚将MySQL更新为“ MySQL社区服务器”! 您可以使用MySQL ODBC连接器,JDBC或本机MySQL或使用MySQLI等各种软件接口连接到MySQL Server。

相关出版物