How to install MySQL in Linux

Source: Internet
Author: User

I. Basic installation

$ Tar zxvf mysql-3.23.58.tar.gz

$ Mysql-3.23.58 cd

$./Configure -- prefix =/usr/local/mysql -- sysconfdir =/etc -- localstatedir =/var/lib/mysql

$ Make

$ Make install

# Prefix =/usr/local/mysql target directory for mysql Installation

# Sysconfdir =/etc my. ini configuration file path

# Localstatedir =/var/lib/mysql database storage path

2. Create mysql user groups and users and set Access Permissions

$ Groupadd mysql

$ Useradd-g mysql # Add a mysql user to the mysql user group

After creating user groups and users, switch to the/usr/local/mysql directory.

$ Cd/usr/local/mysql

Change the access permission of the mysql directory

$ Chown-R mysql. #. indicates the mysql directory and all files and directories in the directory.

Initialize the database after installation. You do not need to perform this step if you upgrade the database;

$/Usr/local/mysql/bin/mysql_install_db

$/Usr/local/mysql/bin/safe_mysqld &

OK. Check if mysql works properly.

Mysql-u root mysql

Generally, the database cannot be connected normally. The error message is:

ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql. sock' (2)

After completing the above steps, COPY a script in your compiled directory

Cp support-files/mysql. server/etc/rc. d/init. d/mysqld

Chkconfig -- add mysqld

Set ntsysv to enable mysql to run automatically at each startup.

Now that mysql is installed, you can start your mysql service.

/Etc/rc. d/init. d/mysqld start

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.