RPM Installation in CentOS 6.5 system configuration MySQL Database

Source: Internet
Author: User
Tags mysql client dmesg

First, MySQL introduction

MySQL is a relational database management system developed by the Swedish MySQL AB company, currently owned by Oracle Corporation. 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. MySQL's SQL language 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.

To install MySQL database on Linux, we can download the MySQL database rpm package on its official website, Http://dev.mysql.com/downloads/mysql/5.6.html#downloads, Everyone can download the corresponding database files according to their operating system, the latest version is 5.6.10.

Here I am the installation of MySQL database through Yum, this way to install, can be related to MySQL some services, jar packages are installed to us, so save a lot of unnecessary trouble!!!

Second, uninstall the original MySQL

Because MySQL database is very popular on Linux, so the mainstream Linux version of the current download basically integrates the MySQL database inside, we can use the following command to see if the MySQL database is installed on our operating system

[Email protected] ~]# Rpm-qa | grep mysql//This command will check if the MySQL database is already installed on the operating system

If there is, we can unload it by RPM-E command or rpm-e--nodeps command.

[[email protected] ~]# rpm-e mysql//normal Delete mode
[[email protected] ~]# rpm-e--nodeps MySQL//brute force Delete mode, if you use the above command to delete, prompted to have other dependent files, then use this command can be strongly deleted

After the deletion we can pass Rpm-qa | grep mysql command to see if MySQL has been uninstalled successfully!!

third, install MySQL

1. Enter the directory of the installation files

2. Install MySQL server

RPM-IVH mysql-server-5.5.25a-1.rhel5.x86_64.rpm

Mysql-server Installation

3. Install MySQL client, mysql-devel

RPM-IVH mysql-client-5.5.25a-1.rhel5.x86_64.rpm
RPM-IVH mysql-devel-5.5.25a-1.rhel5.x86_64.rpm

Mysql-client-devel

At this point we can view the version of the mysql-server that we just installed with the following command

Rpm-qa | grep MySQL

Four, start MySQL service and configuration

After we install the MySQL database, we will find a mysqld service, this is our database service, we can start our MySQL service by entering the service mysqld Start command.

Note: If we are starting the MySQL service for the first time, the MySQL server will first initialize the configuration, such as:

[Root@xiaoluo ~]# Service mysqld start

Initialize MySQL database: warning:the host ' Xiaoluo ' could not being looked up with RESOLVEIP.
This probably means that your libc libraries is not compatible
With this binary MySQL version. The MySQL daemon, mysqld, should work
Normally with the exception that host name resolving won't work.
This means, should use IP addresses instead of hostnames
When specifying MySQL privileges!
Installing MySQL system tables ...
Ok
Filling Help Tables ...
Ok
To start mysqld at boot time with to copy
Support-files/mysql.server to the right place for your system
REMEMBER to SET A PASSWORD for the MySQL root USER!
To does so, start the server, then issue the following commands:
/usr/bin/mysqladmin-u root password ' new-password '
/usr/bin/mysqladmin-u root-h xiaoluo password ' new-password '
Alternatively you can run:
/usr/bin/mysql_secure_installation
Which would also give you the option of removing the test
Databases and anonymous user created by default. This is
Strongly recommended for production servers.
See the Manual for more instructions.
You can start the MySQL daemon with:
CD/USR; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
Cd/usr/mysql-test; Perl mysql-test-run.pl
Problems with The/usr/bin/mysqlbug script!
Determine
Starting mysqld: [OK]

At this point we will see that the first time you start the MySQL server will prompt a lot of information, the purpose is to initialize the MySQL database, when we restart the MySQL service again, will not prompt so much information, such as:

[email protected] ~]# service mysqld Restart
Stop mysqld: [OK]
Starting mysqld: [OK]

When we use MySQL database, we have to start the Mysqld service first, we can through Chkconfig--list | grep mysqld command to see if the MySQL service is booting automatically, such as:

[Email protected] ~]# Chkconfig--list | grep mysqld
Mysqld 0: Off 1: Off 2: Off 3: Off 4: off 5: off 6: Off

We found that the MYSQLD service did not start automatically, and of course we can set it to boot up with the Chkconfig mysqld on command, so you don't have to start it manually every time.

[Email protected] ~]# chkconfig mysqld on
[Email protected] ~]# Chkconfig--list | grep MySQL
Mysqld 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

MySQL database after installation will only have a root administrator account, but at this time the root account has not set a password for it, the first time the MySQL service started, the database will be some initialization work, in the output of a large string of information, we see a line of information:

/usr/bin/mysqladmin-u root password ' new-password '//Set password for root account

So we can use this command to set the password for our root account (Note: This root account is the root account of MySQL, not the root account of Linux)

[[email protected] ~]# mysqladmin-u root password ' root '//Use this command to set the root account password to root

At this point we can log in to our MySQL database via the mysql-u root-p command.

v. Major configuration files for MySQL database

1./ETC/MY.CNF This is the main configuration file for MySQL

We can take a look at some information about this file

[Root@xiaoluo etc]# ls my.cnf

My.cnf
[email protected] etc]# cat MY.CNF
[Mysqld]
Datadir=/var/lib/mysql
Socket=/var/lib/mysql/mysql.sock
User=mysql
# Disabling Symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0
[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid

2./ver/lib/mysql database file storage location for MySQL database

The database files for our MySQL database are usually stored in the/ver/lib/mysql directory.

[Root@xiaoluo ~]# cd/var/lib/mysql/

[Email protected] mysql]# ls-l
Total dosage 20488
-RW-RW----. 1 MySQL mysql 10485760 April 6 22:01 ibdata1
-RW-RW----. 1 MySQL mysql 5242880 April 6 22:01 Ib_logfile0
-RW-RW----. 1 MySQL mysql 5242880 April 6 21:59 ib_logfile1
DRWX------. 2 MySQL mysql 4096 April 6 21:59 MySQL//These two are the default two database files when the MySQL database is installed
Srwxrwxrwx. 1 mysql MySQL 0 April 6 22:01 mysql.sock
DRWX------. 2 MySQL mysql 4096 April 6 21:59 Test//These two are the default two database files when the MySQL database is installed

We can create a database ourselves to verify where the database files are stored

Create a database of our own:

mysql> CREATE DATABASE Xiaoluo;
Query OK, 1 row Affected (0.00 sec)
[Email protected] mysql]# ls-l
Total dosage 20492
-RW-RW----. 1 MySQL mysql 10485760 April 6 22:01 ibdata1
-RW-RW----. 1 MySQL mysql 5242880 April 6 22:01 Ib_logfile0
-RW-RW----. 1 MySQL mysql 5242880 April 6 21:59 ib_logfile1
DRWX------. 2 MySQL mysql 4096 April 6 21:59 MySQL
Srwxrwxrwx. 1 mysql MySQL 0 April 6 22:01 mysql.sock
DRWX------. 2 MySQL mysql 4096 April 6 21:59 test
DRWX------. 2 MySQL mysql 4096 April 6 22:15 Xiaoluo//This is the Xiaoluo database we just created.
[Email protected] mysql]# CD xiaoluo/
[[email protected] xiaoluo]# ls
Db.opt

3./var/log MySQL database log output storage location

Some of our MySQL database's log output is stored in the/var/log directory

[Root@xiaoluo xiaoluo]# CD

[Email protected] ~]# Cd/var/log
[[email protected] log]# ls
Amanda Cron maillog-20130331 Spice-vdagent.log
Anaconda.ifcfg.log cron-20130331 mcelog Spooler
Anaconda.log cups Messages spooler-20130331
Anaconda.program.log dirsrv messages-20130331 SSSD
Anaconda.storage.log DMESG Mysqld.log Tallylog
Anaconda.syslog Dmesg.old ntpstats Tomcat6
Anaconda.xlog Dracut.log Piranha Wpa_supplicant.log
Anaconda.yum.log GDM Pm-powersave.log wtmp
Audit httpd PPP Xorg.0.log
Boot.log Ibacm.log PreLink Xorg.0.log.old
Btmp Lastlog SA Xorg.1.log
btmp-20130401 Libvirt Samba Xorg.2.log
Cluster Luci Secure Xorg.9.log
Consolekit Maillog secure-20130331 Yum.log

Which mysqld.log this file is the log information we have to store our operations with the MySQL database, and we can get a lot of information by looking at the log file.

Because our MySQL database is accessible over the network, not a stand-alone database, where the protocol used is the TCP/IP protocol, we all know that the MySQL database binding port number is 3306, so we can see through the NETSTAT-ANP command, is the Linux system listening on the 3306 port number:

As shown above, the Linux system listens on the 3306 port number is our 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.