Install MySQL under Linux

Source: Internet
Author: User

#1. Download MySQL

1.1 First determine the location of MySQL to install, CD to the appropriate directory ( such as the MySQL directory ), execute the following command

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

1.2 When the download is complete, unzip the download file

TAR-ZXVF mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

#2. Add system MySQL group and MySQL user

under MySQL directory , perform the following two commands separately

Groupadd mysqluseradd-r-G MySQL MySQL

#3. Installing the Database

3.1 Go to MySQL directory (install directory), execute the command below

3.1.1 Modify current directory owner for MySQL user, execute command

Chown-r Mysql:mysql./

3.1.2 Install database: Execute command

./scripts/mysql_install_db--user=mysql

3.1.3 Modify the current directory owner as root User: Execute command

Chown-r Root:root./

3.1.4 Modify the current data directory owner for MySQL User: Execute command

Chown-r Mysql:mysql Data

------------------------the installation of this database is complete-------------------------

#4. Start MySQL service and add boot MySQL service

4.1 Add Boot: Execute command

CP Support-files/mysql.server/etc/init.d/mysql   <!--put the startup script on the boot initialization directory--

4.2 Start MySQL service: Execute command

Service MySQL Start

#5. Modify the root user password for MySQL, the root initial password is empty

Execute command:./bin/mysqladmin-u root password ' password to be set '

#6. Place the MySQL client in the default path

Ln-s/usr/local/mysql/bin/mysql/usr/local/bin/mysql

After installation, you can enter mysql-uroot-p, then enter password to enter MySQL.

After you can use the various MySQL syntax, you can first view database:show databases and other commands to see if the installation is successful

---------------------------------------uninstall MySQLunder Linux ---------------------------------------

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

Check that each MySQL folder is removed cleanly

Find/-name MySQL

The results are as follows:

/var/lib/mysql

/usr/local/mysql

/usr/lib/mysql

/usr/include/mysql

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

4. Delete MySQL users and user groups

Userdel MySQL

Groupdel MySQL

Install MySQL under Linux

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.