(turn) Linux to build MySQL

Source: Internet
Author: User
Tags mysql download mysql view

One, MySQL introduction

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. Two, 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 Three, MySQL install 3.1 configure firewall

1) Add a row 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(允许3306端口通过防火墙)  

2) Restart the firewall

3.2 Installing 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

4) Installation

5) View version

3.3 Installing MySQL

1) Create user

 # groupadd mysql  #添加mysql组      # useradd -g mysql mysql -s /bin/false  #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统  

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

6) Installation
# make install

7) Configuration My.cnf
Mode One: Manual modification

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 ****/ #设置开机启动 (如果机器重启,最好手动重启服务,因为不知道哪些服务需要先起来,所以一般不加入开机启动,所以注释)   # 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服务加入系统环境变量:在最后添加下面这一行     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 the MySQL is just installed 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  
Four, 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 3306Five, 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

Six, 6 MySQL view number of bits

Seven, MySQL status View

mysql> status;

Eight, connect the remote MySQL database in Linux

With the root user, the password is 123456, the ip:192.168.1.100 is connected, and the port is 3306.

# mysql -uroot -p123456 -h 192.168.1.100 -P3306Nine, navicat connect remote MySQL settings

1) connection configuration. (Click Connect)

2) encoding configuration. (Select a Connected tab, right-click, select Connection properties)

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 address: http://blog.csdn.net/clevercode/article/details/45499231 (reprint must indicate this address).

(turn) Linux to build 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.