Uninstall and install MySql in Linux

Source: Internet
Author: User
Tags install perl
In Linux, how does one install JDK and tomcat in the previous sections of MySQL uninstall and install, and how does one install a database for web development? Now let's introduce how to install mysq,

I. preparations:

1. Because RedHat Enterprise 5 comes with a MySQL version, skip this step if you did not select MySql installation before installing Linux, Because I installed it nowUninstallThe steps are as follows:

A. Find the installed myslq version:

# Rpm-Qa | grep MySQL(Note the case sensitivity. If MySQL does not work, change to MySQL)

The installed MySQL package name, such as: mysql-5.0.22-2.1.0.1, is displayed on the screen;

B. Uninstall the searched package name:

# Rpm-e -- nodeps mysql-5.0.22-2.1.0.1(Nodeps indicates force deletion)

C. Search for the package name again. If no result is output, it indicates that MySQL of this version has been uninstalled;

 

2. Prepare the installation resources as follows:

A. perl-DBI-1.5.2-1.fc6.i386.rpm (this package is to install MySQL dependencies, without it MySQL installation can not afford, check whether installation, if the installation does not need, you can through# Rpm-Qa | grep Perl *Check whether the package has been installed. You can find the package on the Linux system disk. Download the package as follows)

 

B. MySQL-server-community-5.0.67-0.rhel5.rpm and MySQL-client-community-5.0.67-0.rhel5.rpm

(FromHttp://dev.mysql.com/downloads/mysql/5.0.htmlDownload the corresponding Linux version)

 

C. Prepare the corresponding installation package and use LeapFTP to upload it to the Linux system/var/FTP/pub through the vsftp server;

 

3. Start installation:

A. Install perl-DBI-1.5.2-1.fc6.i386.rpm first

# Rpm-IVH perl-DBI-1.5.2-1.fc6.i386.rpm

(Check whether the installation is successful# Rpm-Qa | grep Perl-DBI *)

 

B. Install Perl and install MySQL server first.

# Rpm-IVH MySQL-server-community-5.0.67-0.rhel5.rpm

(Check whether the installation is successful# Rpm-Qa | MySQLTo check whether the process is started.# Ps-Ef | grep MySQLBecause the server version has been started after it is installed)

 

C. Install server and install client:

# Rpm-IVH MySQL-client-community-5.0.67-0.rhel5.rpm

(Check whether the installation is successful# Rpm-Qa | MySQL)

 

D. After the installation is completed, test whether the task can be run:

# MySQL

The MySQL> command is successfully installed. Because the default user is root and there is no password, you can directly enter;

 

The above is a practical operation. I hope it will be helpful. Pay attention to the installation sequence.

 

 

Installation and uninstallation of MySQL binary version

 

MySQL of the binary version has been compiled, without the need for configure, make install, and other steps. You only need to configure and use it once and download it easily. You can delete it directly. Now, mysql-standard-4.1.13-pc-linux-gnu-i686.tar.gz is introduced:

 

1.# Chmod4 755Mysql-standard-4.1.13-pc-linux-gnu-i686.tar.gz // change this file to executable permissions

 

2. # tar-xvzfMysql-standard-4.1.13-pc-linux-gnu-i686.tar.gz // copy the directory generated after decompression to/usr/local/and rename it MySQL

 

3.# Groupadd MySQL// Create a MySQL Group
# Useradd mysql-G MySQL// Create a MySQL user and add it to the MySQL Group

 

4.# Cp/usr/local/MySQL/support-files/my-medium.cnf/etc/My. CNF
There are four template files in the support-Files directory. We select one of the MySQL configuration files to overwrite/etc/My. CNF (default system configuration, with performance parameters and some path parameters of MySQL)

 

5.# Cd/usr/local/MySQL// Go to the MySQL directory

#./Scripts/mysql_install_db -- user = MySQL  // Create a table and use a MySQL user to access the table. After the table is initialized, set the access permissions for MySQL and root users.

 

6.# Chown-r Mysql Data// Set the MySQL user to access/usr/local/MySQL/data, which stores MySQL database files. this directory is in/etc/My. configuration in CNF, generated when mysql_install_db.


7.# Chown-r Mysql Data /.// Set the MySQL user to access all files in/usr/local/MySQL/data/MySQL


8.# Chgrp-r MySQL.// Set the MySQL group to access/usr/local/MySQL


9.#/Usr/local/MySQL/bin/mysqld_safe -- user = MySQL &


10. CD/usr/local/MySQL/bin // enter the bin directory

11. # MySQL // run the mysq command

 

 If it is not started or can't connect to local MySQL server through socket '/tmp/MySQL. Sock' appears'

 

Solution: # cd/usr/local/MySQL/support-files // enter this directory

#./MySQL. Server start // startGenerate /Tmp/MySQL. Sock

If /Tmp/MySQL. Sock does not have this file, and MySQL is in Enabled status?

 

Solution:# Netstat-an | grep 3306// View port 3306

# Ps-Ef | grep MySQL// Query the MySQL process


# Kill-9 process number// Forcibly Delete the MySQL process ID

 

#./MySQL. Server start//Start to generate /Tmp/MySQL. Sock

 


What if the command is not obtained by running the MySQL command in any path?

 

Solution: Modify the/etc/profile file and add it to the file.

Path = $ path:/usr/local/MySQL/bin/

Export path (Save and exit the execution of source/etc/profile)

The preceding operations can be performed in any directory.# MySQLCommand

 

What if I want to execute the service MySQL start or restart Stop command? Cannot be old #./MySQL. Server start

Solution: Copy mysql. server to/etc/rc. d/init. d and rename MySQL or create a connection file.

Assume that the current directory is/etc/rc. d/init. d.

For example:# Cp/usr/local/MySQL/support-files/MySQL. Server MySQL(Copy)

Or:# Ln-S/usr/local/MySQL/support-files/MySQL. Server MySQL(Create a connection file)

After completing the preceding operations, You can execute Service MySQL start(Or restart stop)

 

Run the following command to modify the MySQL password:
#/Usr/local/MySQL/bin/mysqladmin-u Root Password yourpassword // The default installation password is blank. For security purposes, you must modify it immediately.
# Chmod 700/etc/init. d/MySQL
# Chkconfig -- add mysqld
# Chkconfig -- level 345 MySQL on // copy a script setting in the compilation directory to enable MySQL to run automatically at each startup
# Service MySQL start
# Netstat-atln
// Start the MySQL Service
// Check whether port 3306 is enabled. Make sure that the port is opened in the firewall.

You can use Telnet localhost 3306 to test the installation. If any, it indicates that the installation is successful. The above is a summary of the network resources and its own operation practices for future use;
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.