How to install and use the MySQL database in Linux

Source: Internet
Author: User
Tags mysql mysql database

First, install MySQL

1. Create a system user running a MySQL database, group (if there is no need to create)

[root@www ~] #useradd –m–s/sbin/nologin MySQL//No working directory, landing Shell for Prohibition

2. Unpack and release the source package and switch to the expanded source package directory

[root@www ~] #tar zxvf mysql-5.0.56.tar.gz-c/usr/src/

[root@www ~] #cd/usr/src/mysql-5.0.56

3. Use. Configure compilation configuration

[Root@www mysql-5.0.56]#./configure--prefix=/usr/local/mysql

4. Compile and install

[Root@www mysql-5.0.56] #make && make install

5. Post-Installation adjustments (examples here for midsize enterprises)

1). Set up a configuration file

[Root@www mysql-5.0.56] #cp suport-file/my-medium.cnf/etc/my.cnf

2). Initializing the database

[Root@www mysql-5.0.56]/usr/local/mysql/bin/mysql_install_db--user=mysql//as MySQL execution

[Root@www mysql-5.0.56]chown–r root.mysql/usr/local/mysql///Change Directory ownership

[Root@www mysql-5.0.56]chown–r Mysql/usr/local/mysql/var//Change Directory ownership

3). Adjust Lib Library path

[Root@www Mysql-5.0.56]echo "/usr/local/mysql/lib/mysql" >>/etc/ld.so.conf

[Root@www mysql-5.0.56]ldconfig//Refresh Dynamic Connection Library search path for changes to take effect

Second, MySQL start control

1. Use Mysqld_safe script to start the service securely

[Root@www mysql-5.0.56]/usr/local/mysql/bin/mysql_safe--user=mysql & Script Launch

[Root@www Mysql-5.0.56]netstat-ntpl | grep 3306//mysql use 3306 port for service by default

You can modify the port configuration line in the [Mysqld] block in the MY.CNF configuration file as needed

2. Add mysqld as a system service

The Mysql.server in the source Package Support_file folder can be replicated to the INIT.D directory as a service startup script and renamed to MySQL for use with chkconfig--add mysqld; chkconfig Mysqldon make it start

[Root@www MYSQL-5.0.56]CP Support-files/mysql.server/etc/init.d/mysqld

[Root@www mysql-5.0.56]chmod +x/etc/init.d/mysqld

[Root@www mysql-5.0.56]chkconfig--add mysqld

[Root@www mysql-5.0.56]chkconfig mysqld on

The above command enables the MYSQLD service to turn off the reboot via the service start Stop command

3. Set the execution path of the MySQL program

[Root@www mysql-5.0.56]export path= $PATH:/usr/local/mysql/bin

[Root@www Mysql-5.0.56]echo "path= $PATH:/usr/local/mysql/bin" >>/etc/profile

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.