Install MySQL under Linux

Source: Internet
Author: User
Tags mysql client iptables

Yesterday was a busy day, until four o'clock in the night, just for one thing. Install MySQL database

MySQL installation is divided into many kinds, one is Yum installation, the second is the program installation, the third is the code installation, these three ways I do not want to introduce each, this article is focused on the problems encountered

I chose the third kind.

Installation steps

to MySQL website download mysql compiled binary installation package, on the download page select Platform: Option Select Linux-generic, then pull the page to the bottom, 64-bit system download linux-generic (GLIBC 2.5) (x86, 64-bit), 32-bit system download linux-generic (GLIBC 2.5) (x86, 32-bit)

My present is Mysql-5.6.37-linux-glibc2.12-x86_64.tar, link https://dev.mysql.com/downloads/mysql/5.6.html#downloads

Step two unzip the file tar mysql-5.6.17-linux-glibc2.5-i686.tar.gz

The third step is to copy the extracted files to the USR directory under CP mysql-5.6.17-linux-glibc2.5-i686/usr/local/mysql-r

Fourth step Add system user and System user group Groupadd MySQL and Useradd-r-g MySQL MySQL

Fifth Step

Go to install MySQL software directory: Execute command cd/usr/local/mysql

Modify current directory owner for MySQL User: Execute command chown-r mysql:mysql.

Install database: Executes the command./scripts/mysql_install_db--user=mysql

Modify the current directory owner as root User: Execute command chown-r root:root.

Modify the current data directory owner for MySQL User: Execute command chown-r mysql:mysql data

Sixth step:

Start the MySQL service and add the boot MySQL service:

Add MySQL as service: Execute command CP Support-files/mysql.server/etc/init.d/mysql, put startup script into boot initialization directory

granting Permissions chmod +x/etc/init.d/mysql

Add service chkconfig--add MySQL

Open Service chkconfig--level 345 mysql on

Put the MySQL client in the default path: Ln-s/usr/local/mysql/bin/mysql/usr/local/bin/mysql

Start MySQL service: Execute command service MySQL start

This step may cause an error, can ' t connect to local MySQL server through socket ' Tmp/mysql.sock ' (2)

Or can ' t connect to local MySQL server through socket ' Tmp/mysql.sock ' (111)

The first one is because you can't find the. sock file, and the second is a. sock file is not valid

Because service MySQL start defaults to creating a sock file for the connection, the location of the. Sock file is default in the/var/lib/mysql directory, and MySQL reads the file in/tmp,

So it will cause this error, if you go to/var/lib/mysql this file MV to/tmp you will find that the error is gone, but nobody wants to be so troublesome, so you can modify the configuration file My.cnf (/USR/LOCAL/MYSQL/MY.CNF)

Change the socket file directory to/tmp

[Mysqld]

Sql_mode=no_engine_substitution,strict_trans_tables
Socket=/tmp/mysql.sock
port=3306

[MySQL]
Socket=/tmp/mysql.sock
port=3306

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

Finally open 3306 port, otherwise the external cannot connect

/sbin/iptables-i input-p TCP--dport 8000-j ACCEPT
Save
/etc/rc.d/init.d/iptables Save
Restart Service
Service Iptables Restart

Install MySQL 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.