Install MySQL database using a Binary Package

Source: Internet
Author: User

Install MySQL database using a Binary Package

1.1 install MySQL database in Binary Package

1.1.1 preparations before installation (specifications)

[Root @ Mysql_server ~] # Mkdir-p/home/zhurui/tools # create a specified toolkit storage path
[Root @ Mysql_server ~] # Wget http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.5/mysql-5.5.32-linux2.6-x86_64.tar.gz # download Binary Package
[Root @ Mysql_server tools] # tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz # unzip the Mysql package
[Root @ Mysql_server tools] # useradd-s/sbin/nologin-M mysql # create a mysql user
[Root @ Mysql_server tools] # id mysql
Uid = 501 (mysql) gid = 501 (mysql) groups = 501 (mysql)
[Root @ Mysql_server ~] # Mkdir/application/
[Root @ Mysql_server home] # mv/home/zhurui/tools/mysql-5.5.32-linux2.6-x86_64/application/mysql-5.5.32
[Root @ Mysql_server tools] # ll/application/
Total 4
Drwxr-xr-x. 13 root 4096 Dec 13 mysql-5.5.32
[Root @ Mysql_server tools] # ln-s/application/mysql-5.5.32 // application/mysql # Set soft links
[Root @ Mysql_server tools] # ll/application/
Total 4
Lrwxrwxrwx. 1 root 26 Dec 13 14:39 mysql->/application/mysql-5.5.32/
Drwxr-xr-x. 13 root 4096 Dec 13 mysql-5.5.32
[Root @ Mysql_server tools] # ll/application/mysql/
Total 76
Drwxr-xr-x. 2 root 4096 Dec 13 14:31 bin
-Rw-r --. 1 7161 wheel 17987 Jun 19 2013 COPYING
Drwxr-xr-x. 3 root 4096 Dec 13 14:31 data
Drwxr-xr-x. 2 root 4096 Dec 13 docs
Drwxr-xr-x. 3 root 4096 Dec 13 14:31 include
-Rw-r --. 1 7161 wheel 7470 Jun 19 2013 INSTALL-BINARY
Drwxr-xr-x. 3 root 4096 Dec 13 14:31 lib
Drwxr-xr-x. 4 root 4096 Dec 13 14:31 man
Drwxr-xr-x. 10 root 4096 Dec 13 14:31 mysql-test
-Rw-r --. 1 7161 wheel 2496 Jun 19 2013 README
Drwxr-xr-x. 2 root 4096 Dec 13 14:31 scripts
Drwxr-xr-x. 27 root 4096 Dec 13 share
Drwxr-xr-x. 4 root 4096 Dec 13 SQL-statements
Drwxr-xr-x. 3 root 4096 Dec 13 14:31 support-files

1.1.2 initialize the database

[Root @ Mysql_server tools] #/application/mysql/scripts/mysql_install_db -- basedir =/application/mysql/-- datadir =/application/mysql/data/-- user = mysql # Initialization database
Installing MySQL system tables...
OK
Filling help tables...
OK
[Root @ Mysql_server tools] # ll/application/mysql/data/# view initialization results
Total 12
Drwx ------. 2 mysql root 4096 Dec 13 mysql
Drwx ------. 2 mysql 4096 Dec 13 performance_schema
Drwxr-xr-x. 2 mysql root 4096 Dec 13 test

1.1.3 authorize Mysql to manage database files

[Root @ Mysql_server ~] # Chown-R mysql. mysql/application/mysql/
[Root @ Mysql_server ~] # Ll/application/mysql
Lrwxrwxrwx. 1 mysql 26 Dec 13/application/mysql->/application/mysql-5.5.32/

1.1.4 generate the Mysql configuration file

[Root @ Mysql_server tools] # \ cp/application/mysql/support-files/my-small.cnf/etc/my. cnf

1.1.5 configure to start Mysql

[Root @ Mysql_server tools] # sed-I's #/usr/local/mysql #/application/mysql # G'/application/mysql/bin/mysqld_safe/application/mysql/ support-files/mysql. server
[Root @ Mysql_server tools] # cp/application/mysql/support-files/mysql. server/etc/init. d/mysqld # copy the generated STARTUP script to init. d directory
[Root @ Mysql_server tools] # chmod + x/etc/init. d/mysqld

1.1.6 start Mysql

[Root @ Mysql_server tools] # lsof-I: 3306 # Check whether the Mysql service is enabled
[Root @ Mysql_server tools] #
[Root @ Mysql_server tools] #/etc/init. d/mysqld start # start the Mysql Service
Starting MySQL... SUCCESS!
[Root @ Mysql_server tools] # lsof-I: 3306
Command pid user fd type device size/OFF NODE NAME
Mysqld 2235 mysql 10u IPv4 22761 0t0 TCP *: mysql (LISTEN)
[Root @ Mysql_server tools] #

1.1.7 configure Environment Variables

Method 1:

[Root @ Mysql_server tools] # cp/application/mysql/bin/*/usr/local/sbin/# method 1

Method 2:

[Root @ Mysql_server tools] # tail-1/etc/profile
PATH = "/application/mysql/bin: $ PATH" # Add the following lines at the end
[Root @ Mysql_server tools] # source/etc/profile # Make the configuration take effect

1.1.8 set and change the password

[Root @ Mysql_server tools] # mysqladmin-uroot password 123456
[Root @ Mysql_server tools] # mysqladmin-uroot-p123456 password zhurui

2.1 database management

[Root @ Mysql_server tools] # mysql-uroot-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 8
Server version: 5.5.32 MySQL Community Server (GPL)

Copyright (c) 2000,201 3, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.

Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.

Mysql> show databases; # view the database;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Performance_schema |
| Test |
+ -------------------- +
4 rows in set (0.00 sec)

Mysql> drop database test; # Delete the test database;
Query OK, 0 rows affected (0.00 sec)

Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Performance_schema |
+ -------------------- +
3 rows in set (0.00 sec)

Mysql> select user, host from mysql. user; # view the user list;
+ ------ + --------------- +
| User | host |
+ ------ + --------------- +
| Root | 127.0.0.1 |
| Root |: 1 |
| Mysql \ _ server |
| Root | Mysql \ _ server |
| Localhost |
| Root | localhost |
+ ------ + --------------- +
6 rows in set (0.00 sec)

Mysql> drop user root @ ': 1'; # Delete useless users
Query OK, 0 rows affected (0.00 sec)

Mysql> drop user ''@ 'mysql \ _ Server'; # Cannot delete uppercase or special characters. The following describes
Query OK, 0 rows affected (0.00 sec)

Mysql> drop user ''@ 'localhost ';
Query OK, 0 rows affected (0.01 sec)

Mysql> drop user 'root' @ 'mysql \ _ Server'; cannot delete uppercase or special characters. The following describes
Query OK, 0 rows affected (0.00 sec)

Mysql> select user, host from mysql. user;
+ ------ + --------------- +
| User | host |
+ ------ + --------------- +
| Root | 127.0.0.1 |
| Mysql \ _ server |
| Root | Mysql \ _ server |
| Root | localhost |
+ ------ + --------------- +
4 rows in set (0.00 sec)
You cannot delete uppercase or special characters. solution:
Mysql> delete from mysql. user where user = "" and host = "Mysql \ _ server ";
Query OK, 1 row affected (0.02 sec)

Mysql> delete from mysql. user where user = "root" and host = "Mysql \ _ server ";
Query OK, 1 row affected (0.00 sec)

Mysql> select user, host from mysql. user; # view the user list after deleting useless users
+ ------ + ----------- +
| User | host |
+ ------ + ----------- +
| Root | 127.0.0.1 |
| Root | localhost |
+ ------ + ----------- +
2 rows in set (0.00 sec)
Mysql> flush privileges; # Make the permission take effect
Query OK, 0 rows affected (0.00 sec)

Create a user SQL statement:

Mysql> grant all on *. * to 'root' @ 'localhost' identified by '000000' with grant option; flush privileges;

CentOS7 compilation and installation MySQL 5.6.28 and compilation Parameters

MySQL binary log operations

MySQL 5.6.12 database compilation and installation in Linux

Install MySQL 5.6 with the source code in CentOS 7

How to install and configure MySQL5.7.3.0

Install MySQL in Ubuntu 14.04

MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF

Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL

This article permanently updates the link address:

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.