Create a MySQL Database

Source: Internet
Author: User
Tags one table

I. Introduction to the Database
1. Database: Store user's personal information, user's game information, etc.

2. Database composition: Multiple records form one table, multiple tables form a library

3. Database classification:

1) Relational database: Adopt E-r Graph (Entity-relation), consist of three elements of entity, attribute and relation, there is some kind of correlation in each middle.

2) Non-relational database: There is no correlation in the middle, can improve the query speed

For example: MySQL, SQL Server, Oracle, etc. are relational databases; Redis, memcached, etc. are non-relational databases

Second, compile and install MySQL5.5
1) Preparatory work
RPM-E mysql-server mysql//uninstall install MySQL package using RPM method

2) Configure local Yum source
rm-rf/etc/yum.repos.d/*//Delete all your own Yum source profiles

Vim/etc/yum.repos.d/local.repo

MOUNT/DEV/CDROM/MNT Mounting Discs
Yum-y Install Ncurses-devel//installation dependent packages

TAR-ZXVF cmake-2.8.6.tar.gz-c/usr/src/

Unzip the CMake software package, MySQL uses cmake to compile without using the. Configure method

cd/usr/src/cmake-2.8.6/

./configure && make && make install

2) source code compilation and installation
A. Creating a running user
Groupadd MySQL//create Run program group
Useradd-m-s/sbin/nologin-g mysql mysql//new program user and join MySQL group, do not allow login system
B. Unpacking
Cd
TAR-ZXVF mysql-5.5.22.tar.gz-c/usr/src/
cd/usr/src/mysql-5.5.22/
C. Configuration
Cmake-dcmake_install_prefix=/usr/local/mysql-ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dwith_ Extra_charsets=all-dsysconfdir=/etc
-dcmake_install_prefix: Specify MySQL installation location
-ddefault_charset: Specifying the default character set encoding
-ddefault_collation: Specifies that character set proofing rules are used by default
-dwith-extra-charsets: Specify additional support for other character set encodings
-dsysconfdir: Configuration file storage location
D. Compiling and installing
Make && make install
3) Other adjustments after installation
A. Setting permissions on a database directory
Chown-r mysql:mysql/usr/local/mysql/
B. Creating a configuration file
RM-RF/ETC/MY.CNF//delete default presence my.cnf file
CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
C. Initializing the database
/usr/local/mysql/scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql/--datadir=/usr/local/mysql/ data/
Execute initialization script
--user: Specify running User
--basedir: Specifying the MySQL database location
--datadir: Specifying the MySQL data storage location
D. Setting environment variables
echo "path= $PATH:/usr/local/mysql/bin" >>/etc/profile
Add MySQL to search path for easy command execution
Source/etc/profile//Immediately let profile file contents take effect
4) Adding system services
CP Support-files/mysql.server/etc/rc.d/init.d/mysqld
Copy Service script file to/ETC/RC.D/INIT.D location
chmod +x/etc/rc.d/init.d/mysqld
Chkconfig--add mysqld
Chkconfig–-level mysqld on
/etc/init.d/mysqld Start or service mysqld start
NETSTAT-UTPLN | grep mysqld

Note: The default MySQL service is provided via TCP 3306 port, can edit port = 3306 line of [mysqld] segment in/ETC/MY.CNF, change listening ports

2. Accessing the MySQL Database
MySQL is a typical C/s (client/server) architecture, access to the database requires specialized client software, Linux system, you can use the self-contained MySQL command tool
1) login to MySQL server
After initializing the script, the MySQL database default administrator user name "root" (not system root), the password is empty
Mysql-u root//-u Designated authentication user, can be used for no password login
Mysql-u root-p//-p Specify password, no password required after user interactive input password
2) Execute MYSQ operation statement
After successful verification, enter the "mysql>" prompt, and the user enters various action statements to manage the database. Each MySQL operation statement is separated by a semicolon ";" Indicates the end; input is not case sensitive
Mysql-u Root
Mysql>show master logs; View log file information for the current database service

3) Exit "mysql>" operating environment
In the "mysql>" operating system, execute "exit" or "quit" to exit the MySQL command tool
mysql>exit;

Create a MySQL Database

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.