Linux Learning CentOS (13) installation and configuration of MySQL database under--centos6.4

Source: Internet
Author: User
Tags dmesg
If you want to do j2ee development on Linux, you must first build the j2ee development environment, including the installation of jdk, tomcat, eclipse (this has already explained in detail in the previous essay on Linux learning CentOS (seven)- J2ee environment under CentOS), if we want to develop a web project, we can of course install a myeclipse to the Linux system. This installation method is exactly the same as installing eclipse, there is no record. With jdk, tomcat, eclipse, we can already We have developed our program, but if we want to make a project, even a small project cannot be separated from the storage of data! ! ! That's right, we are still missing one of the most important software, which is the database! ! ! If you do n’t have a database, it ’s almost a fantasy to do a project, so for the database installation, I wrote this essay specifically for installing the mysql database. . . . . .

1. Introduction to mysql

When it comes to databases, we mostly think of relational databases, such as mysql, oracle, sqlserver, etc. These database software are very convenient to install on windows. If you want to install a database on Linux, we have to first recommend mysql The database, and the first version of the Mysql database is released on the Linux system.

MySQL is a relational database management system developed by the Swedish MySQL AB company and currently belongs to Oracle. MySQL is a relational database management system. Relative databases store data in different tables instead of putting all data in a large warehouse, which increases speed and flexibility. MySQL's SQL language is the most commonly used standardized language for accessing databases. The MySQL software adopts a dual authorization policy (this entry "authorization policy"), which is divided into a community version and a commercial version. Due to its small size, fast speed, and low total cost of ownership, especially open source, it is generally small and medium-sized. Website development chooses MySQL as the website database. Due to the excellent performance of its community version, a good development environment can be formed with PHP and Apache.

Install the mysql database on Linux, we can go to its official website to download the rpm package of the mysql database, http://dev.mysql.com/downloads/mysql/5.6.html#downloads, you can download the corresponding according to your operating system The latest version of the database file is 5.6.10.

Here I installed the mysql database through yum. By installing in this way, we can install some services and jar packages related to mysql for us, so it saves a lot of unnecessary trouble! ! !

Second, uninstall the original mysql

Because the mysql database is so popular on Linux, the mainstream Linux system versions currently downloaded are basically integrated with the mysql database. We can use the following command to check whether the mysql database has been installed on our operating system.

[[email protected] ~] # rpm -qa | grep mysql // This command will check whether the mysql database has been installed on the operating system
If there is, we can uninstall it by rpm -e command or rpm -e --nodeps command

[[email protected] ~] # rpm -e mysql // Ordinary delete mode
[[email protected] ~] # rpm -e --nodeps mysql // Powerful deletion mode, if you use the above command to delete, you are prompted to depend on other files, you can use this command to force delete
After deleting, we can use rpm -qa | grep mysql command to check whether mysql has been uninstalled successfully! !

Third, install mysql through yum

I used yum to install the mysql database. First, we can enter the yum list | grep mysql command to view the downloadable version of the mysql database provided on yum:

[[email protected] ~] # yum list | grep mysql
You can get the downloadable version information of the mysql database on the yum server:

 

 

Then we can install mysql mysql-server mysql-devel by entering yum install -y mysql-server mysql mysql-devel command Yes, we still need to install the mysql-server server)

 

[[email protected] ~] # 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 affiliated software

 

 

We found that installing the mysql database through yum saves a lot of unnecessary trouble. When the following results appear, it means that the mysql database was successfully installed

 

 

At this time, we can view the version of the mysql-server just installed by the following command

 

[[email protected] ~] # rpm -qi mysql-server
 

The mysql-server we installed is not the latest version. If you want to try the latest version, go to the mysql official website to download the rpm package and install it. Our mysql database has been installed.

Four, mysql database initialization and related configuration

After we install the mysql database, we will find that there will be an additional mysqld service. This is our database service. We can start our mysql service by entering the service mysqld start command.

Note: If we start the mysql service for the first time, the mysql server will first perform the initial configuration, such as:

[[email protected] ~] # service mysqld start

Initialize the MySQL database: WARNING: The host ‘xiaoluo’ could not be looked up with resolveip.
This probably means that your libc libraries are not 100% compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you 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 you have to copy
support-files / mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER!
To do 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 will 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

Please report any problems with the / usr / bin / mysqlbug script!

                                                           [determine]
Starting mysqld: [OK]
 

At this time, we will see a lot of information after starting the mysql server for the first time. The purpose is to initialize the mysql database. When we restart the mysql service again, we will not prompt so much information, such as:

 

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

When we use the mysql database, we must first start the mysqld service. We can use the chkconfig --list | grep mysqld command to check whether the mysql service is automatically started at boot, such as:

 

[[email protected] ~] # chkconfig --list | grep mysqld
mysqld 0: close 1: close 2: close 3: close 4: close 5: close 6: close
 

We found that the mysqld service does not start automatically at boot. Of course, we can use the chkconfig mysqld on command to set it to boot, so that we do n’t have to manually start it every time

 

[[email protected] ~] # chkconfig mysqld on
[[email protected] ~] # chkconfig --list | grep mysql
mysqld 0: close 1: close 2: enable 3: enable 4: enable 5: enable 6: close
 

After the mysql database is installed, there will only be a root administrator account, but the root account has not yet set a password for it. When the mysql service is started for the first time, some initialization work will be performed on the database. In the message, we see this line of information:

 

/ usr / bin / mysqladmin -u root password ‘new-password’ // Set a password for the root account
 

So we can use this command to set a password for our root account (note: this root account is the root account of mysql, non-Linux root account)

 

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

At this point, we can log in to our mysql database through the mysql -u root -p command

 

Five, the main configuration file of the mysql database

1./etc/my.cnf This is the main configuration file of mysql

We can check some information of this file

[[email prot
ected] 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./var/lib/mysql mysql database database file storage location

The database files of our mysql database are usually stored in the / ver / lib / mysql directory

 

[[email protected] ~] # cd / var / lib / mysql /
[[email protected] mysql] # ls -l
Total amount 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 two default 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 are the two default database files when the mysql database is installed
 

We can create a database ourselves to verify the storage location of the database file

 

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 ourselves
[[email protected] mysql] # cd xiaoluo /
[[email protected] xiaoluo] # ls
db.opt
3. The log output storage location of the / var / log mysql database

Some of the log output of our mysql database is stored in the / var / log directory

[[email protected] 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
 

Among them, the mysqld.log file is some log information that we store when we operate with the mysql database. By viewing the log file, we can get a lot of information from it

 

Because our mysql database is accessible through the network, not a stand-alone database, the protocol used is tcp / ip protocol, we all know that the port number of the mysql database is 3306, so we can use the netstat -anp command Let's check if the Linux system is listening to the port number 3306:

The result is as shown above, the port number 3306 monitored by the Linux system is our mysql database! ! ! !

 

This essay details the installation of mysql database and basic configuration of the database through yum under CentOS6.4. In the subsequent Linux learning, I will insist on recording my own experience and experience! ! ! !

Perseverance is victory! ! ! ! ! ! ! ! ! !

Linux Learning CentOS (Thirteen)-Mysql database installation and configuration under CentOS6.4

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.