Using Yum and make to install MySQL method in Linux

Source: Internet
Author: User
Tags flush mkdir mysql in

Yum install MySQL

First, install MySQL.
Yum List | grep MySQL; Select the appropriate version, Yum intall the version;
Yum List | grep mysql-server; Select the appropriate version, Yum intall the version.
After the installation is complete, add the MYSQLD service.
/sbin/chkconfig–-add mysqld [Add MySQL service to the list of services]
Then start to start MySQL.
Service mysqld start (ie/etc/init.d/mysqld start). can also be set to boot from:/sbin/chkconfig mysqld on)
Then, uh ... What if the "MySQL Daemon failed to start" message appears? This is how you solve it.
1. Initializing the database
/usr/bin/mysql_install_db--user=mysql
CP/USR/SHARE/MYSQL/MY-SMALL.CNF/ETC/MY.CNF (optional)
2. Login to MySQL in safe mode
CD/USR;
/usr/bin/mysqld_safe &
3. Start the MYSQLD service again when you are ready.
The following are the general actions:
Change root password: mysqladmin-u root password ' newpassword '
Add MySQL User: GRANT all privileges on my_db.* to ' user ' @ ' localhost ' identified by ' password ';
Delete Test database: mysql-u root-p mysql> DROP database test;
Delete Anonymous account: Delete from mysql.user WHERE user = ';
Overloaded permissions: mysql> FLUSH privileges;
Set some initial parameters, such as default encoding (MY.CNF) (if no my.cnf, you can cp/usr/share/mysql/my-small.cnf/etc/my.cnf)
Vi/etc/my.cnf
[Mysqld]
Datadir=/var/lib/mysql
Socket=/var/lib/mysql/mysql.sock
User=mysql
Default-character-set=utf8 [Add]
Default-storage-engine=innodb [Add]
Old_passwords=1
[Client]
Default-character-set=utf8 [Add]
[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid

If you are unable to connect on another computer because the host field of root is localhost, change it to%.
Use MySQL
Update user set host= '% ' where host= ' localhost ' and user= ' root ';
Flush privileges;

Wrap

Update

For other machines to access, add a user with a host of '% ' in mysql.user and then flush
Priviledges, the last firewall plus a sentence like this can be (open 3306 port):

-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT

If you want to reboot from start:


Chkconfig--levels 345 mysqld on


Make install MySQL

Installation environment: Linux Server CentOS 5.5

Installed version: mysql-5.5.8.tar.gz

1, install CMake compiler.

1), download CMake

#cd/USR/LOCAL/SRC

#wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz

2), decompression CMake

#tar-ZVXF cmake-2.8.4.tar.gz

3), configuration compilation

#cd cmake-2.8.4
#yum-y Install gcc
#yum-y Install gcc-c++
#yum-y Install Ncurses-devel
#./configure
#make
#make Install

2, install MySQL

1), download MySQL.

#cd/USR/LOCAL/SRC

#wget http://sdk.ruiya.com/linux/mysql-5.5.9.tar.gz

2), add the necessary groups and owners

#groupadd MySQL

#useradd-R-G MySQL MySQL

3), decompression MySQL

#tar-ZVXF mysql-5.5.9.tar.gz

4), configuration compilation

If you are reloading MySQL, please delete my.cnf first: rm-rf/etc/my.cnf

#mkdir/usr/local/mysql

#mkdir/usr/local/mysql/data

#cd/usr/local/src/mysql-5.5.9

#cmake.
-dcmake_install_prefix=/usr/local/mysql
-dinstall_datadir=/usr/local/mysql/data
-ddefault_charset=utf8
-ddefault_collation=utf8_general_ci
-dextra_charsets=all
-denabled_local_infile=1

Parameter description:

-dcmake_install_prefix=/usr/local/mysql//installation directory
-dinstall_datadir=/usr/local/mysql/data//Database storage directory
-ddefault_charset=utf8//using UTF8 characters
-DDEFAULT_COLLATION=UTF8_GENERAL_CI//Checksum character
-dextra_charsets=all//Install all extended character sets
-denabled_local_infile=1//Allow import of data from local

#make

#make Install

Note:

When recompiling, the old object files and cached information need to be purged.

# Make Clean
# rm-f CMakeCache.txt
# RM-RF/ETC/MY.CNF

4), set directory permissions

# Cd/usr/local/mysql

# Chown-r Root:mysql. Set the owner owner of all files in the current directory to root and belong to MySQL

# chown-r Mysql:mysql Data

5), configuration file

# CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF//This configuration is only suitable for small memory systems (32M-64M)

Open the following comment:

Innodb_data_home_dir =/usr/local/mysql/data
Innodb_data_file_path = Ibdata1:10m:autoextend
Innodb_log_group_home_dir =/usr/local/mysql/data

Innodb_buffer_pool_size = 16M
Innodb_additional_mem_pool_size = 2M

Innodb_log_file_size = 5M
Innodb_log_buffer_size = 8M
Innodb_flush_log_at_trx_commit = 1
Innodb_lock_wait_timeout = 50

To add a default character set:

[Client]
Default-character-set = UTF8//Add encoding support
[Mysqld]
Default-character-set = UTF8//Add encoding support
Max_connections = 10000//Per Server performance tuning
Basedir =/usr/local/mysql//Set up the installation directory so that the system can run correctly to/etc/rc.d/init.d/mysql start when it starts

6), create the System database table

# Cd/usr/local/mysql

# scripts/mysql_install_db--user=mysql

7), set permissions to start

To set environment variables:

# Vi/root/.bash_profile

In path= $PATH: $HOME/bin add parameters to:

Path= $PATH: $HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib

#source/root/.bash_profile

Manually start MySQL:

# Cd/usr/local/mysql

#./bin/mysqld_safe--user=mysql &/Start MySQL, but can't stop

Startup log is written under this file:/usr/local/mysql/data/localhost.err

Turn off MySQL service

# mysqladmin-u Root-p shutdown//Here MySQL root user has not yet configured password, so null value.

To start MySQL with a script:

# ln-s/usr/local/mysql/support-files/mysql.server/usr/local/mysql
It must be noted that it is placed in the MySQL directory, not in the bin directory
# Cp/usr/local/mysql/support-files/mysql.server/usr/local/mysql
# mysql.server start/starting MySQL
# mysql.server stop/Shut down MySQL

To start MySQL at boot time:

# ln-s/usr/local/mysql/support-files/mysql.server/etc/rc.d/init.d/mysql

# ln-s/usr/local/mysql/mysql.server/etc/rc.d/init.d/mysql
# CD/ETC/RC.D/INIT.D
# chkconfig--add MySQL//configuration is automatically started, chkconfig--del MySQL can be deleted
# chmod +x/etc/rc.d/init.d/mysql//Add such as Execute permission


Tips
Linux Run Level:
It is divided into 8 running levels, 7 of which are commonly used. Can be set in the/etc/inittab file.
0-halt
1-single User mode
2-multiuser, without NFS
3-full multiuser mode
4-unused
5-x11
6-reboot
The default setting is: Id:3:initdefault:
Each dynamic row level has a self-contained folder, such as:
/ETC/RC.D/RC3.D indicates that the configuration with a run level of 3 is stored in this file-man.

# chkconfig--list |grep mysql/check to see if set to self start
MySQL 0: off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off
: Run Level 2, 3, 4, 5 will automatically start MySQL

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.