MySQL installation and use in Linux (centos-6.5:mysql-5.5.27)

Source: Internet
Author: User



1 MySQL profile MySQL is a relational database management system developed by the Swedish MySQL AB company, currently owned by Oracle Corporation. MySQL is the most popular relational database management system, and in Web applications MySQL is one of the best RDBMS (relational database Management system: relational databases Management systems) application software. MySQL is an associated database management system that keeps data in separate tables rather than putting all of the data in a large warehouse, which increases speed and increases flexibility. The SQL language used by MySQL is the most commonly used standardized language for accessing databases. MySQL software uses a dual licensing policy (this term "authorization policy"), it is divided into community and commercial version, because of its small size, speed, low total cost of ownership, especially the open source of this feature, the general small and medium-sized web site development has chosen MySQL as the site database. Thanks to the performance of its community edition, PHP and Apache make a good development environment.


2 mysql download 1) Download CMake (MySQL compilation tool)
# wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz

2) Download MySQL. The previous version may no longer exist because of a version update. Go to MySQL to find it.
# http://dev.mysql.com/Downloads/MySQL-5.5/mysql-5.5.27.tar.gz

3) This installation of all software resource packages

http://download.csdn.net/detail/clevercode/8662323


3 MySQL Install 3.1 Configure Firewall 1) Add a line of 3306 ports to the firewall configuration file
# Vi/etc/sysconfig/iptables #编辑防火墙配置文件
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT (Allow 3306 ports via firewall)
2) Restart the firewall
#/etc/init.d/iptables Restart #最后重启防火墙使配置生效


3.2 Install CMake 1) unzip. Before installing, make sure to install Linux standby Support library and install the necessary common support library in Linux: http://blog.csdn.net/clevercode/article/details/45438401.
# Cd/usr/local/src/mysql
# tar ZXVF cmake-2.8.8.tar.gz
# CD cmake-2.8.8

2) configuration
#./configure

3) Compiling
# make

4) Installation
# make Install

5) View version
# cmake-version

3.3 Install MYSQL1) create user
# groupadd MySQL #添加mysql组
# useradd-g MySQL mysql-s/bin/false #创建用户mysql并加入到mysql组, do not allow MySQL users to log in directly to the system


2) Configure MySQL database storage directory and installation directory
# mkdir-p/data0/mysql #创建MySQL数据库存放目录
# chown-r Mysql:mysql/data0/mysql #设置MySQL数据库目录权限
# mkdir-p/usr/local/mysql #创建MySQL安装目录


3) Unzip
# Cd/usr/local/src/mysql
# tar ZXVF mysql-5.5.27.tar.gz
# CD mysql-5.5.27


4) configuration
# CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/data0/mysql-dsysconfdir=/etc


5) Compiling
# make


6) Installation
# make Install


7) Configuration My.cnf
Mode One: Manual modification
# Cd/usr/local/mysql
# CP./SUPPORT-FILES/MY-HUGE.CNF/ETC/MY.CNF #拷贝配置文件 (Note: If the/etc directory has a my.cnf under the default, you can overwrite it directly)
# vi/etc/my.cnf #编辑配置文件, add the following line in the [mysqld] section
DataDir =/data0/mysql #添加MySQL数据库路径
: wq! #保存退出


Mode two: Use the already configured file (config file: http://download.csdn.net/detail/clevercode/8662323)
Backup
# cp/etc/my.cnf/etc/my.cnf_bak_20141117
# CD/ETC
# RZ MY.CNF


8) Generate MySQL system database
# Cd/usr/local/mysql
#./scripts/mysql_install_db--user=mysql


9) Start the MySQL join system
# CP./SUPPORT-FILES/MYSQL.SERVER/ETC/RC.D/INIT.D/MYSQLD #把Mysql加入系统启动
# chmod 755/etc/init.d/mysqld #增加执行权限
/******* chkconfig mysqld on ****/#设置开机启动 (if the machine restarts, it is best to manually restart the service, because do not know which services need to get up first, so generally do not join boot boot, so comments)
# Vi/etc/rc.d/init.d/mysqld #编辑
Basedir=/usr/local/mysql #MySQL程序安装路径
Datadir=/data0/mysql #MySQl数据库存放目录
Service mysqld Start #启动


10) Add the MySQL service to the system environment variable
# vi/etc/profile #把mysql服务加入系统环境变量: Add the following line at the end
Export path= $PATH:/usr/local/mysql/bin
: wq! #保存退出


11) Specify the MySQL library file address
The following two lines link the MYSLQ library file to the default location of the system, and you can compile software like PHP without specifying the MySQL library file address.
# ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
# ln-s/usr/local/mysql/include/mysql/usr/include/mysql


12) Change the root password of MySQL. After MySQL is installed, the default password for root is empty.
Way One:
MySQL default root user does not have password, enter mysql-uroot into MySQL
# Mysql-uroot
Mysql>update user Set Password=password (' 123456 ') where user= ' root ';
Mysql>flush privileges;


Way two:
1) If you just installed MySQL or the password is empty, it is modified in the following way.
#/usr/local/mysql/bin/mysqladmin-u root password "123456"
2) If it is not just installed and the password is not empty, use the following method. Add-p, prompting you to enter your old password.
#/usr/local/mysql/bin/mysqladmin-u root-p Password "123456"


13) Restart
# Service Mysqld Restart


4 MySQL start stop restart 1) status
# Service MYSQLD Status

2) Start
# service Mysqld Start

3) Stop
# Service Mysqld Stop

4) Restart
# Service Mysqld Restart

5) View 3306 Port listening status
# Netstat-an | grep 3306


5 MySQL configuration telnet 1) Configure all IPs to access
#mysql-uroot-p123456
Mysql> Grant all privileges on * * to ' root ' @ '% ' identified by ' 123456 ' with Grant OPTION;
mysql> flush Privileges;

2) Configuration development IP can be accessed
If you want to allow the user jack to connect to the MySQL server from the IP-10.10.50.127 host and use 654321 as the password
Mysql>grant all privileges on * * to ' jack ' @ ' 101.10.50.127 ' identified by ' 654321 ' with GRANT OPTION;
Mysql>flush rivileges;

3) Configure a user that is similar to the root user who can have all permissions
Mysql> Grant all privileges on * * to ' clevercode ' @ '% ' identified by ' clevercode#er239 ' with Grant OPTION;
mysql> flush Privileges;

6 MySQL view bits mysql> show variables like '%version_% ';
The version_compile_machine:i686 is 32 bits and the x86_64 is 64 bits.



7 MySQL Status View mysql> status;



8 Navicat Connection Encoding settings

If the write is GBK, then use Navicat read out should also use GBK, regardless of the database is stored with what code. If the write is UTF8, then the client should also use UTF8 when reading the data. For example, when PHP writes is GBK, then navicat reads the data with GBK encoding. Set to: 936 (ansi/oem-simplified Chinese GBK)



original works, from "Clevercode's blog" , please be sure to mention the following original address when reproduced , otherwise hold the copyright legal responsibility.

Original Address : http://blog.csdn.net/clevercode/article/details/45499231 ( reprint must indicate this address ).

Welcome to pay attention to my blog more wonderful content: Http://blog.csdn.net/CleverCode.



MySQL installation and use in Linux (centos-6.5:mysql-5.5.27)

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.