How to uninstall and install MySQL database under Linux

Source: Internet
Author: User
Tags mysql download

1.1 MySQL Download

: Http://www.mysql.com/downloads/mysql/5.5.html#downloads

Version: 5.1.68

Platform: Linux General

Generic Linux (glibc 2.3) (x86, 64-bit), RPM package
Version: MySQL Server

(mysql-server-5.1.68-1.glibc23.x86_64.rpm)

Note: This is not the newest version, but it is the version I used earlier, consider compatibility, use this version.

1.2 Check the old version and uninstall

1. Find out if MySQL was previously installed

Command: Rpm-qa|grep-i MySQL

You can see two of the MySQL packages:

mysql-4.1.12-3.rhel4.1

mysqlclient10-3.23.58-4.rhel4.1

2. Delete MySQL

Delete command: RPM-E--nodeps package Name

(Rpm-ev mysql-4.1.12-3.rhel4.1)

3, delete the old version of MySQL development header files and libraries

Command: Rm-fr/usr/lib/mysql

Rm-fr/usr/include/mysql

Note: The data and/etc/my.cnf in/var/lib/mysql after uninstallation are not deleted, if determined, then manually deleted

Rm-f/etc/my.cnf

Rm-fr/var/lib/mysql

1.3 Installation

[Email protected] soft]# RPM-IVH mysql-server-5.1.68-1.glibc23.x86_64.rpm

Preparing ... ########################################### [100%]

1:mysql-server ########################################### [100%]

REMEMBER to SET A PASSWORD for the MySQL root USER!

To does so, start the server, then issue the following commands:

/usr/bin/mysqladmin-u root password ' new-password '

/usr/bin/mysqladmin-u root-h localhost.localdomain password ' new-password '

Alternatively you can run:

/usr/bin/mysql_secure_installation

Which would also give you the option of removing the test

Databases and anonymous user created by default. This is

Strongly recommended for production servers.

See the Manual for more instructions.

Problems with The/usr/bin/mysqlbug script!

Starting MySQL. success!

[[email protected] soft]# MySQL

-bash:/bin/mysql: No file or directory

1.4 Log in to MySQL

The command is MySQL, and MySQL uses the following syntax:
MySQL [-u username] [-h host] [-p[password]] [dbname]
Username and password are mysql user name and password, MySQL's initial management account is root, no password, note: This root user is not a Linux system user. MySQL Default user is root, because the initial no password, the first time to enter the only need to type MySQL.

MySQL does not have a password by default, the importance of increasing the password is self-evident.

1. Command

usr/bin/mysqladmin-u root password ' new-password '

Format: Mysqladmin-u username-P Old password password new password

2. Example

Example 1: Add a password to root 123456.

Type the following command:

[Email protected] local]#/usr/bin/mysqladmin-u root password 123456

Note: Because Root does not have a password at the beginning, the-p old password can be omitted.

3. Test whether the modification is successful

1) Login without password

[[email protected] local]# MySQL

ERROR 1045:access denied for user: ' [email protected] ' (Using password:no)

An error is displayed stating that the password has been modified.

2) Log in with the modified password

[Email protected] local]# mysql-u root-p

1.5 finally give access (very important, otherwise the client does not connect)

GRANT all privileges on * * to ' root ' @ '% ' identified by ' 123456 ' with GRANT OPTION;

Assign users from any IP address a permission limit for all operations on all tables in all databases, and set the password to ' 123456 '.

How to uninstall and install MySQL database under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.