Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The whole process of uninstalling and installing Mysql

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Mysql is a familiar concept and a new field of knowledge. Begin my journey of learning all-round database.

Everything, starting from the installation, do it yourself every step.

During the installation of Linux, you can check the installation of Mysql, but the version installed is Mysql-5.1.73, which is very low. Must be reinstalled, the current latest version is 5.7. But uninstalling and then installing is obviously a little more troublesome than a blank Linux installation.

Let's start the uninstall / installation process.

1. Download address of Mysql

Mysql-5.7.22-1.el6.x86_64.rpm-bundle.tar https://dev.mysql.com/downloads/file/?id=476884

two。 Confirm the OS version

# more / etc/issueCentOS release 6.7 (Final) Kernel\ r on an\ m # lsb_release-aLSB Version:: base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarchDistributor ID: CentOSDescription: CentOS release 6.7 (Final) Release: 6.7Codename: Final

3. According to the OS version, find the Mysql version that needs to be downloaded, and right-click "Save Link as" to get the download address.

4. Go to Linux and download via wget

Wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.18-1.el6.x86_64.rpm

The following three rpm packages have dependencies and need to be downloaded

# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-common-5.7.18-1.el6.x86_64.rpm# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-client-5.7.18-1.el6.x86_64.rpm# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-libs-5.7.18-1.el6.x86_64.rpm

5. Check the query and find that Mysql-5.1.73 has been installed and the version is very low. Must be reinstalled, the current latest version is 5.7

# rpm-qa | grep mysqlmysql-server-5.1.73-5.el6_6.x86_64mysql-libs-5.1.73-5.el6_6.x86_64mysql-5.1.73-5.el6_6.x86_64mysql-connector-odbc-5.1.5r1144-7.el6.x86_64

6. Ready to install, before installation, doubt, will it be overwritten? Will there be conflict? Try to install it and you'll see.

Install 4 rpm packages simultaneously

# rpm-ivh mysql-community-server-5.7.18-1.el6.x86_64.rpm mysql-community-client-5.7.18-1.el6.x86_64.rpm mysql-community-common-5.7.18-1.el6.x86_64.rpm mysql-community-libs-5.7.18-1.el6.x86_64.rpm

7. There was a conflict.

Warning: mysql-community-server-5.7.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... # [100%] file / usr/share/mysql/czech/errmsg.sys from install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64file / usr/share/mysql/danish/errmsg.sys from Install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64file / usr/share/mysql/dutch/errmsg.sys from install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64file / usr/share/mysql/english/errmsg.sys from install of mysql- Community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64file / usr/share/mysql/estonian/errmsg.sys from install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64.

8. After query, the installation also failed, or version 5.1.73

# rpm-qa | grep mysqlmysql-server-5.1.73-5.el6_6.x86_64mysql-libs-5.1.73-5.el6_6.x86_64mysql-5.1.73-5.el6_6.x86_64mysql-connector-odbc-5.1.5r1144-7.el6.x86_64

9. Start to uninstall the original 5.1.73 Mysql, several uninstall methods, the first to uninstall YUM mode

# yum remove mysql# rpm-e mysql / / normal delete mode # rpm-e-- nodeps mysql / / forcefully delete mode. If you are prompted to delete other dependent files when deleting using the above command, you can use this command to delete them.

10. There are two bags left.

# rpm-qa | grep mysqlmysql-libs-5.1.73-5.el6_6.x86_64mysql-connector-odbc-5.1.5r1144-7.el6.x86_64

11. Perform a yum localinstall installation and find that you need to uninstall mysql-libs-5.1.73-5.el6_6.x86_64. After uninstalling the package through yun, you can install it.

# yum localinstall mysql-community-server-5.7.18-1.el6.x86_64.rpm mysql-community-client-5.7.18-1.el6.x86_64.rpm mysql-community-common-5.7.18-1.el6.x86_64.rpm mysql-community-libs-5.7.18-1.el6.x86_64.rpm~~~Loaded plugins: fastestmirror, refresh-packagekit SecuritySetting up Local Package ProcessExamining mysql-community-server-5.7.18-1.el6.x86_64.rpm: mysql-community-server-5.7.18-1.el6.x86_64Marking mysql-community-server-5.7.18-1.el6.x86_64.rpm to be installedLoading mirror speeds from cached hostfile* base: mirrors.163.com* extras: mirrors.cn99.com* updates: mirrors.163.comExamining mysql-community-client-5.7.18-1.el6.x86_64.rpm Mysql-community-client-5.7.18-1.el6.x86_64Marking mysql-community-client-5.7.18-1.el6.x86_64.rpm to be installedExamining mysql-community-common-5.7.18-1.el6.x86_64.rpm: mysql-community-common-5.7.18-1.el6.x86_64Marking mysql-community-common-5.7.18-1.el6.x86_64.rpm to be installedExamining mysql-community-libs-5.7.18 -1.el6.x86_64.rpm: mysql-community-libs-5.7.18-1.el6.x86_64Marking mysql-community-libs-5.7.18-1.el6.x86_64.rpm to be installedResolving Dependencies-- > Running transaction check--- > Package mysql-community-client.x86_64 0rig 5.7.18-1.el6 will be installed--- > Package mysql-community-common.x86_64 0rig 5.7.18-1.el6 will be installed > Package mysql-community-libs.x86_64 0buret 5.7.18-1.el6 will be installed--- > Package mysql-community-server.x86_64 0vir 5.7.18-1.el6 will be installed-- > Finished Dependency ResolutionDependencies Resolved=Package Arch Version Repository Size=Installing:mysql-community-client x86 _ 64 5.7.18-1.el6 / mysql-community-client-5.7.18-1.el6.x86_64 100 Mmysql-community-common x86 "64 5.7.18-1.el6 / mysql-community-common-5.7.18-1.el6.x86_64 2.5 Mmysql-community-libs x86" 64 5 .7.18-1.el6 / mysql-community-libs-5.7.18-1.el6.x86_64 8.9 Mmysql-community-server x86'64 5.7.18-1.el6 / mysql-community-server-5.7.18-1.el6.x86_64 769 MTransaction Summary=Install 4 Package (s) Total size: 880 MInstalled size: 880 MIs this ok [y / N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionInstalling: mysql-community-common-5.7.18-1.el6.x86_64 1/4Installing: mysql-community-libs-5.7.18-1.el6.x86_64 2/4Installing: mysql-community-client-5.7.18-1.el6.x86_64 3/4Installing: mysql-community-server-5.7.18-1.el6.x86_64 4/4Verifying: mysql-community-server-5.7.18-1.el6.x86_64 1/4Verifying: mysql-community-libs-5.7.18-1.el6.x86_64 2/4Verifying: mysql-community-common-5.7.18-1.el6.x86_64 3/4Verifying: mysql-community-client-5.7.18-1.el6.x86_64 4/4Installed: Mysql-community-client.x86_64 0VOR 5.7.18-1.el6MySQL house community-common.x86_64 0VOV 5.7.18-1.el6mysql-community-libs.x86_64 0RV 5.7.18-1.el6MySQL house communityserver.x86_64 0Rom 5.7.18-1.el6Complete!

twelve。 Final check, installation has been successful

# rpm-qa | grep mysqlmysql-community-client-5.7.18-1.el6.x86_64mysql-community-libs-5.7.18-1.el6.x86_64mysql-community-common-5.7.18-1.el6.x86_64mysql-community-server-5.7.18-1.el6.x86_64

13. The installation completed, but there was a problem at startup:

# service mysqld restartStopping mysqld: [OK] Initializing MySQL database: 2017-07-11T15:23:50.462866Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use-explicit_defaults_for_timestamp server option (see documentation for more details). 2017-07-11T15:23:50.465315Z 0 [ERROR]-- initialize specified but the data directory has files in it. Aborting.2017-07-11T15:23:50.465365Z 0 [ERROR] Aborting [FAILED]

14. Baidu's solution (because the previous version of the database already occupies this folder and needs to be emptied, or re-specified in / etc/my.cnf-- datadir)

Make sure-- the datadir directory is empty. / usr/local/var/mysql this directory

15. Started successfully

# cd / var/lib/mysql# lsauto.cnf ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1# rm * rm: remove regular file `auto.cnf'? Yrm: remove regular file `ib_buffer_pool'? Yrm: remove regular file `ibdata1'? Yrm: remove regular file `ib_logfile0'? Yrm: remove regular file `ib_logfile1'? Y

# service mysqld restart

Stopping mysqld: [OK] Initializing MySQL database: [OK] Installing validate password plugin: [OK] Starting mysqld: [OK]

# ps-ef | grep mysql

Root 4533 10 23:25 pts/0 00:00:00 / bin/sh / usr/bin/mysqld_safe-- datadir=/var/lib/mysql-- socket=/var/lib/mysql/mysql.sock-- pid-file=/var/run/mysqld/mysqld.pid-- basedir=/usr-- user=mysqlmysql 4727 4533 4 23:25 pts/0 00:00:00 / usr/sbin/mysqld-basedir=/usr-- datadir=/var/lib/mysql-- plugin-dir=/ Usr/lib64/mysql/plugin-user=mysql-log-error=/var/log/mysqld.log-pid-file=/var/run/mysqld/mysqld.pid-socket=/var/lib/mysql/mysql.sockroot 4762 3752 0 23:25 pts/0 00:00:00 grep mysql

16. However, in the process of starting, I encountered some problems. I didn't know the password, so I reset the password.

# mysql-u rootERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@test mysql] # mysql-u root-pEnter password:ERROR 1045 (28000): Access denied for user' root'@'localhost' (using password: YES)

Edit the mysql configuration file / etc/my.cnf, add skip-grant-tables under the entry [mysqld] and restart mysql after saving and exiting.

# vi / etc/my.cnf

[root@test mysql] # service mysqld restartStopping mysqld: [OK] Starting mysqld: [OK]

# mysql

Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 4Server version: 5.7.18 MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c' to clear the current input statement.mysql > show databases;+-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | sys | +-+ 4 rows in set (0.00 sec)

Set the password and delete the skip-grant-tables in / etc/my.cnf

Restart mysql again

Mysql > use mysql;Database changed

-. Set a new password for the root user:

Prior to version 5.7:

Mysql > update user set password=password ("new password") where user= "root"; Query OK, 1 rows affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0

After version 5.7, the password field is no longer available in the mysql database, and the password field has been changed to authentication_string.

Update mysql.user set authentication_string=PASSWORD ('oracle') where User='root';mysql > flush privileges;Query OK, 0 rows affected (0.00 sec)

-exit mysql, restart and log in again

# service mysqld restartStopping mysqld: [OK] Starting mysqld: [OK]

# mysql-uroot-poracle

Mysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 5Server version: 5.7.18Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql >

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report