2 ways to install MySQL database in Linux

Source: Internet
Author: User
Tags flush mysql in

Compile and install MySQL

Prepare before installation

If the MySQL user does not exist, then add the MySQL user

Groupadd MySQL
useradd-g MySQL MySQL

MySQL Compile installation

wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.70.tar.gz
TAR-ZXVF mysql-5.1.70.tar.gz
CD mysql-5.1.70

Yum Install ncurses Ncurses-devel
./configure '--prefix=/usr/local/mysql '--without-debug '--with-charset=utf8 '--with-extra-charsets=all ' Enable-assembler '--with-pthread '--enable-thread-safe-client '--with-mysqld-ldflags=-all-static '-- With-client-ldflags=-all-static '--with-big-tables '--with-readline '--with-ssl '--with-embedded-server ' Enable-local-infile '--with-plugins=innobase '
Make
Make install

To this MySQL is installed to the/usr/local/mysql path, the following start MySQL configuration work
------------------------------------

Installing the MySQL options file


CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF

MySQL Settings boot from boot

Cp-r Support-files/mysql.server/etc/init.d/mysqld
/sbin/chkconfig--del mysqld
/sbin/chkconfig--add mysqld
Configure Permission Table

Chown-r Mysql:mysql/usr/local/mysql
/usr/local/mysql/bin/mysql_install_db--user=mysql
Start MySQL

/etc/init.d/mysqld start

This step may be an error

/etc/init.d/mysqld:line 260:my_print_defaults:command not found
/etc/init.d/mysqld:line 263:my_print_defaults:command not found
/etc/init.d/mysqld:line 270: @HOSTNAME @: Command not found
/etc/init.d/mysqld:line 279: @HOSTNAME @: Command not found
/etc/init.d/mysqld:line 292:CD: @prefix @: No such file or directory
Starting mysqlcouldn ' t find MySQL Manager (@bindir @/mysqlmanager) or server (@bindir @/mysqld_safe) [FAILED]

Because the path does not have a setting, please reboot to confirm that the configuration work is complete, generally after configure without make, and make install.

MySQL initialization configuration:

Export Path=/usr/local/mysql/bin: $PATH
/usr/local/mysql/bin/mysql_secure_installation

How MySQL imports the old data:

Copy the database folder directly to the data directory and execute

/usr/local/mysql/bin/mysqladmin-u root-p Flush-tables


problems in MySQL installation process

1.
MAKE[2]: Entering directory '/down/webinstall/mysql-5.1.57/mysql-test
MAKE[3]: Entering directory '/down/webinstall/mysql-5.1.57/mysql-test
MAKE[3]: Nothing is done for ' install-exec-am.
Make install_to_dir= "/usr/local/mysql/mysql-test" install_test_files
MAKE[4]: Entering directory '/down/webinstall/mysql-5.1.57/mysql-test
Longer time

MySQL installed here for a long time, may think that a mistake, in fact, MySQL has been installed successfully, it this step over time will be good, is MySQL in the self-compiling test results.

2.checking for termcap functions Library ... configure:error:No curses/termcap Library found
Yum Install ncurses Ncurses-devel

3.Starting Mysql.manager of Pid-file quit without updating fi[failed]

Before starting the database, you need to configure the permissions table, where/usr/local/mysql is the MySQL installation directory
Chown-r Mysql:mysql/usr/local/mysql
/usr/local/mysql/bin/mysql_install_db--user=mysql

The above installation of MySQL is compiled by way of installation, this time do not compile, direct installation.


[Root@hk tools]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz
[Root@hk tools]# tar zxf mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz
[ROOT@HK tools]# MV mysql-5.6.16-linux-glibc2.5-x86_64/opt/
[ROOT@HK opt]# mv mysql-5.6.16-linux-glibc2.5-x86_64 MySQL
[Root@hk opt]#/usr/sbin/useradd mysql-s/sbin/nologin-m
[Root@hk opt]# CD mysql/
[Root@hk mysql]#/opt/mysql/scripts/mysql_install_db--basedir=/opt/mysql/--datadir=/opt/mysql/data--user=mysql
[Root@hk mysql]# Mv/etc/my.cnf/etc/my.cnf.backup
[Root@hk mysql]# sed-i ' s#\# socket = ... # socket =/tmp/mysql.sock#g ' my.cnf
[Root@hk mysql]# cp/opt/mysql/my.cnf/etc/my.cnf
[Root@hk mysql]#/opt/mysql/support-files/mysql.server start
[Root@hk mysql]# NETSTAT-TUNLP
Active Internet connections (only servers)
Proto recv-q Send-q Local address Foreign address State Pid/program Name
TCP 0 0::: 3306:::* LISTEN 28104/mysqld
[Root@hk mysql]#/opt/mysql/bin/mysql-uroot-p
Enter Password:
ERROR 2002 (HY000): Can ' t connect to the local MySQL server through socket '/tmp/mysql.sock ' (2) #看下面的sock的配置
[Root@hk mysql]# sed-i ' s#\# socket = ... # socket =/tmp/mysql.sock#g ' my.cnf
[Root@hk mysql]#/opt/mysql/bin/mysql-uroot-p
Enter Password:
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes) #居然报错
[Root@hk mysql]#/opt/mysql/bin/mysqld_safe--skip-grant-tables &
[1] 30062
mysql> Update Mysql.user Set Password=password (' admin123 ') where user= ' root '; #设置密码
mysql> flush Privileges;
[Root@hk mysql]# Skill 30194
[Root@hk mysql]# 140601 00:14:38 mysqld_safe mysqld from PID File/opt/mysql/data/hk.t4x.org.pid ended
[1]+ Done/opt/mysql/bin/mysqld_safe--skip-grant-tables
[Root@hk mysql]#/opt/mysql/bin/mysql-uroot-p
Enter Password:
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes) #错误依旧
[Root@hk mysql]# vim/usr/local/mysql/support-files/mysql.server #配置文件中默认配置目录是/usr/local/mysql
[Root@hk mysql]# ln-s/opt/mysql/usr/local/mysql #设置软连接
[Root@hk mysql]#/usr/local/mysql/bin/mysql-uroot-p ' admin123 '
Mysql>

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.