Installing and configuring MySQL database under Linux centos

Source: Internet
Author: User
Tags mysql version dmesg

Suppose you want to do a Java EE development on Linux. First of all, we must set up the development environment of Java EE. Includes the installation of JDK, Tomcat, eclipse (this has been explained in a previous essay on the Linux learning CentOS (vii)--centos under the Java EE Environment ), suppose to develop a Web project, Of course we can install a myeclipse to the Linux system, and this installation method and installation eclipse are no longer documented, with JDK, Tomcat, and eclipse we are already able to develop our programs. But suppose to do a project, even small can not be smaller projects are inseparable from the storage of data!!. Yes, we have one of the most important software is not installed, that is, the database!!

Assuming there is no database, we are simply daydreaming about doing the project. So, for the database installation this block. Specifically for the installation of MySQL database wrote this essay ...

。。

First, MySQL simple introduction

Speaking of databases. Most of what we think of is a relational database. For example, MySQL, Oracle, SQL Server, and so on, these database software installed on Windows is very convenient, on Linux assumption to install the database. I had to recommend the MySQL database first. And the first version number of the MySQL database is distributed on Linux systems.

MySQL is a relational database management system developed by the Swedish MySQL AB company. Now belongs to Oracle Corporation. MySQL is an associated database management system. The associated database saves the data in a different table, rather than putting all the data in a large warehouse. This adds speed and increases flexibility. MySQL's SQL language is the most frequently used standardized language for access to 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, fast, low overall cost of ownership, especially the open source code this feature, the general development of small and medium-sized sites have chosen MySQL as a site database. Because of the performance of its community edition, PHP and Apache can form a good development environment.

Installing MySQL database on Linux, we were able to download the MySQL database rpm package to its official website. Http://dev.mysql.com/downloads/mysql/5.6.html#downloads, you can download the corresponding database files according to your own operating system. Now the latest version number is 5.6.10.

Here I install the MySQL database through Yum, which is installed in this way. We can install some services and jar packages related to MySQL, so we save a lot of unnecessary trouble.

Second, uninstall the original MySQL

Since MySQL database is so popular on Linux, the major Linux system version numbers that are currently being downloaded are basically integrated into the MySQL database. We can see if the MySQL database is already installed on our operating system, for example by the following command

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- normal Delete mode Brute force delete mode. If you use the above command to delete, prompting for other dependent files, you can use this command to strongly delete

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

Third, the installation of MySQL through Yum

I am using yum to perform MySQL database installation, first we can enter Yum List | grep mysql command to view the downloadable version number of the MySQL database available on Yum:

Yum grep MySQL

You will be able to get the downloadable version number information for the MySQL database on the yumserver:

Then we were able to install the MySQL mysql-server mysql-devel by entering the yum install-y mysql-server mysql mysql-devel command ( Note: When we installed MySQL, we did not install the mysqlclient, which is the equivalent of installing MySQL database. We also need to install Mysql-server server.

Yum Install -y mysql-server mysql Mysql-deve

After waiting for some time, Yum will help us choose the software needed to install the MySQL database and some other ancillary software.

We found that installing the MySQL database through the Yum method eliminates a lot of unnecessary hassle when the following results occur. Successfully installed on behalf of MySQL database

At this point we can view the version number of the newly installed Mysql-server by using the following command, for example

[Email protected] ~]# Rpm-qi mysql-server

The mysql-server we installed is not the latest version number, assuming you want to try the latest version number. Then go to the MySQL website to download the RPM package installed. Now that our MySQL database has been installed.

Iv. initialization of MySQL database and related configuration

After we install the MySQL database. Will find an extra mysqld service, this is our database service, we can start our MySQL service by entering the service mysqld start command.

Note : Assuming that we are starting the MySQL service for the first time, MySQLServer first initializes the configuration. Such as:

[[Email protected] ~]# Service mysqld start initializing MySQL database: Warning:the host'Xiaoluo'Could not being looked up with Resolveip. This probably means that your libc libraries is not -%compatiblewith This binary MySQL version. The MySQL daemon, mysqld, should worknormally with the exception that host name resolving won't work. This means, should use IP addresses instead of Hostnameswhen specifying MySQL privileges!Installing MySQL system tables ... Okfilling Help Tables ... OKto start mysqld at boot TimeYou have to Copysupport-files/mysql.server to the right place foryour systemplease REMEMBER to SET A PASSWORD for the MySQL root USER! to DoSo, start the server, Thenissue 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_installationwhichWould also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended forproduction servers. See the manual for  Moreinstructions. You can start the MySQL daemon with:cd/usr; /usr/bin/mysqld_safe &can test the MySQL daemon with MySQL-test-RUN.PLCD/usr/mysql-test;Perlmysql-test-run.plplease Report any problems with the/usr/bin/mysqlbug script![OK] is starting mysqld: [OK]

We'll see a lot of information when we start MySQLServer for the first time. The goal is to initialize the MySQL database, and when we start the MySQL service again and again, we don't prompt so much information, such as:

[[Email protected] ~Service mysqld Restart stop mysqld:                                             [OK] starting mysqld:                                          [OK]

When we use the MySQL database, we have to start the Mysqld service first, and we are able to see if the MySQL service is booting itself by chkconfig--list | grep mysqld command. Such as:

grep mysqldmysqld              0: Off    1: Off    2: Off    3: Off    4: Off    5: Off    6: Off

We found that the MYSQLD service did not boot itself, and of course we were able to set it to boot by chkconfig mysqld on command. So you don't have to start it manually every time.

[[Email protected] ~grep  mysqlmysqld             0: Off    1: Off    2 : Enable    3: Enable    4: Enable    5: Enable    6: Off

After the MySQL database is installed, there will only be a root administrator account, but at this time the root account has not set 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 like this:

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

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

mysqladmin-u root Password ' Root '//Use this command to set the root account password to root

At this point we are able to 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 look at some information about this file

LScat  my.cnf [mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/  Mysql.sockuser=mysql# Disabling symbolic-links are recommended to prevent assorted security Riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file =/var/run/mysqld/mysqld.pid

2. Storage location of database files for/var/lib/mysql MySQL Database

The database files of our MySQL database are usually stored in the/ver/lib/mysql folder.

[Email protected] ~]# cd/var/lib/mysql/[email protected] mysql]#ls-L Total Dosage20488-RW-RW----.1MySQL MySQL10485760April6  A: onibdata1-RW-RW----.1MySQL MySQL5242880April6  A: onIb_logfile0-RW-RW----.1MySQL MySQL5242880April6  +: -ib_logfile1drwx------.2MySQL MySQL4096April6  +: - MySQL//These two are the default two database file srwxrwxrwx when the MySQL database is installed .1MySQL MySQL0April6  A: onmysql.sockdrwx------.2MySQL MySQL4096April6  +: - Test //These two are the default two database files when the MySQL database is installed 

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

 Create a database of our own:MySQL>CREATE DATABASE Xiaoluo; Query OK,1Row affected (0.00sec) [Email protected] mysql]#ls-L Total Dosage20492-RW-RW----.1MySQL MySQL10485760April6  A: onibdata1-RW-RW----.1MySQL MySQL5242880April6  A: onIb_logfile0-RW-RW----.1MySQL MySQL5242880April6  +: -ib_logfile1drwx------.2MySQL MySQL4096April6  +: -mysqlsrwxrwxrwx.1MySQL MySQL0April6  A: onmysql.sockdrwx------.2MySQL MySQL4096April6  +: -testdrwx------.2MySQL MySQL4096April6  A: the Xiaoluo//This is the Xiaoluo database we just created [[email protected] mysql]# CD Xiaoluo/[email protected] xiaoluo]#lsdb.opt

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

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

[ Email protected] xiaoluo]# CD [[email protected]~]# cd/var/Log[[email protected] log]#lsAmanda Cron Maillog-20130331spice-Vdagent.loganaconda.ifcfg.log Cron-20130331Mcelog spooleranaconda.log cups messages spooler-20130331anaconda.program.log dirsrv Messages-20130331sssdanaconda.storage.log dmesg mysqld.log tallyloganaconda.syslog dmesg.old NT Pstats tomcat6anaconda.xlog dracut.log Piranha Wpa_supplicant.loganaconda.Yum. log GDM pm-powersave.log wtmpaudit httpd PPP Xorg.0. Logboot.log ibacm.log prelink Xorg.0. log.oldbtmp lastlog sa Xorg.1. Logbtmp-20130401Libvirt Samba Xorg.2. Logcluster Luci Secure Xorg.9. Logconsolekit Maillog Secure-20130331    Yum. log

In Mysqld.log, this file is the log information we have about our operations with the MySQL database, and we can get a lot of information from it by looking at the log file.

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

As seen above, the Linux system listens to the 3306port number is our MySQL database!!

!!

This essay specifically records the installation of MySQL database with Yum under CentOS6.4 and the basic configuration of the database, and in the likely Linux learning will persist in recording their own experience and experience!

!!!

Installing and configuring MySQL database under Linux centos

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.