Install mysql in linux

Source: Internet
Author: User
Tags gz file

Install mysql in linux

Install mysql

Download the mysql-standard-4.1.8-pc-linux-i686.tar.gz file to the directory/usr/local /.

# Groupadd mysql // Add a mysql user group

# Useradd-g mysql // log on to the mysql user group

# Tar-zxvf mysql-standard-4.1.8-pc-linux-i686.tar.gz // unzip the installation package

# Rm-f mysql-standard-4.1.8-pc-linux-i686.tar.gz // Delete compressed package

# Mv mysql-standard-4.1.8-pc-linux-i686 mysql // put the files in the mysql-standard-4.1.8-pc-linux-i686 In the mysql file folder and delete the mysql-standard-4.1.8-pc-linux-i686 folder

# Cd mysql // enter the mysql folder

# Cp/usr/local/mysql/support-files/my-medium.cnf/etc/my. cnf // copy the configuration file to/etc/and rename it my. cnf: Indicates whether to overwrite the duplicate file.

# Scripts/mysql_install_db -- user = mysql // initialize the database as a mysql user, which must be a mysql user

# Chown-R root. // note the following: Set the owner of all files and subdirectories in the current directory as the root user.

# Chown-R mysql data // indicates that the owner of the data directory under the current directory is set as a mysql user

# Chgrp-R mysql. // note that the file group in the current directory is set to mysql.

# Bin/mysqld_safe -- user = root & // & indicates that the background is started.

If "... Ended. Press enter to display the command input line.

 

Check whether mysql is started:

# Ps-aux | grep mysqld

The following information is displayed:

Root 14105 0.0 0.0 3896 660 pts/0 S + grep mysqld

Root 14304 0.0 0.0 4452 1092? S Apr24 0: 00/bin/sh./mysqld_safe -- user = mysql

Mysql 14327 0.0 0.7 41024 14508? S Apr24 0: 01/usr/local/mysql/bin/mysqld -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data -- user = mysql -- pid- file =/usr/local/mysql/data/localhost. localdomain. pid -- skip-locking -- port = 3306 -- socket =/tmp/mysql. sock

Mysql 14328 0.0 0.7 41024 14508? S Apr24 0: 01/usr/local/mysql/bin/mysqld -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data -- user = mysql -- pid- file =/usr/local/mysql/data/localhost. localdomain. pid -- skip-locking -- port = 3306 -- socket =/tmp/mysql. sock

Mysql 14329 0.0 0.7 41024 14508? S Apr24 0: 00/usr/local/mysql/bin/mysqld -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data -- user = mysql -- pid- file =/usr/local/mysql/data/localhost. localdomain. pid -- skip-locking -- port = 3306 -- socket =/tmp/mysql. sock

Check whether mysql is listening on the Port:

# Netstat-tl | grep mysql

You can see the following similar content:

Tcp 0 0 *: mysql *: * LISTEN

 

Possible errors:

Can't connect to local Mysql server through socket '/tmp/mysql. sock' to check whether the "socket" configuration file in/etc/my. cnf exists

For example:/etc/my. socket =/tmp/mysql in cnf. sock requires mysql under/tmp. if the sock file does not exist, # touch/tmp/mysql. sock // create mysql. sock File

 

Can't create/write to file '/usr/local/mysql/data/localhost. localdomain. pid 'has this type of error, check the permission problem and whether there is localhost. localdomain. pid File

Command for permission setting: # chown-R command for file creation: # touch

 

When mysql has been started and the service has not been stopped and restarted, the error "Can't create/write to file"/usr/local/mysql/data/localhost. localdomain. pid "may also occur.

 

Uninstall mysql

# Rpm-qa | grep-I mysql

The following information may appear:

MySQL-server-4.1.8-0

MySQL-client-4.1.8-0

If yes, run the following command:

# Rpm-ev MySQL-server-4.1.8-0 MySQL-client-4.1.8-0

Then manually delete the/usr/local/mysql folder and configuration file.

# Rm-rf/usr/local/mysql

# Rm-f/etc/my. cnf


Install MYsql in linux

Actually you can install it to the opt directory rpm-ivh -- nodeps mysql-server-5.0.45-7.el5.i386.rpm/opt
Opt is an optional application directory

Suggested to download a package, mysql-5.1.30.tar.gz
This eliminates the need to download the mysql dependency package.
Directly decompress the package and enter the file. /configure-prefix = target location -- with-charset = gbk -- with-extra-charsets = all (generate compliant files) & make (compile) & make install (installation)
Note: before installation, uninstall the original installed mysql
Rpm-qa mysql
Rpm-e -- nodeps mysql (delete all relevance)
-- Nodeps (if this package is dependent on other packages, it should be forced if it is not installed in time)

Install mysql in linux

./Configure -- prefix =/usr/local/mysql
The installation method is source code installation.

Check your directory and find that you have a BINARY execution package. You cannot use./configure. Check the bin directory or try to run INSTALL-BINARY.

----
PS: attaches a MYSQL installation package installed with source code. It has been tested to be OK and can be installed on CentOS 4.7 ------
Wget downloads.mysql.com/..tar.gz
# Download the mysql source code package

// • Install and start mysql, and set the password for the root account of mysql
# Groupadd mysql
# Useradd-m mysql-g mysql-d/usr/local/mysql
# Tar xvfz mysql-5.0.87.tar.gz
# Cd mysql-5.0.87
#. /Configure -- prefix =/usr/local/mysql -- localstatedir =/home/var -- with-charset = utf8 -- with-extra-charsets = all -- with-berkeley-db -- -innodb -- without-readline -- enable-consumer er -- with-pthread -- enable-thread-safe-client -- with-client-ldflags =-all-static
# Make
# Make install
# Check whether/etc/my. cnf exists. If yes, modify the path pointing to it. Otherwise, the database table file may not be installed under/home/var.

#/Usr/local/mysql/bin/mysql_install_db -- user = mysql
# Chown-R mysql: mysql/home/var // Set permissions. Otherwise, mysqld_safe cannot be executed.
#/Usr/local/mysql/bin/mysqld_safe -- user = mysql &
# Cp./support-files/mysql. server/etc/rc. d/init. d/mysql // set mysql to start automatically
# Chmod + x/etc/rc. d/init. d/mysql
# Chkconfig -- add mysql
// Add mysql to the service list. If mysql is followed by -- add,/etc/rc. d/init. d/mysql is displayed.
# Service mysql start
#/Usr/local/mysql/bin/mysqladmin-u root password st ...... the remaining full text>

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.