In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
If we want to do j2ee development on Linux, we must first set up the development environment of j2ee, including the installation of jdk, tomcat and eclipse (this has been explained in detail in a previous essay on the CentOS of Linux learning (7)-- setting up the j2ee environment under CentOS). If we want to develop a web project, we can of course install a myeclipse to the Linux system, which is exactly the same as installing eclipse. With jdk, tomcat, eclipse, we will be able to develop our program, but if we want to do a project, even the smallest project can not be separated from data storage! Yes, we still need one of the most important software, that is, the database! Without the database, it would be a pipe dream for us to do the project, so for the database installation, I wrote this essay specifically for installing the mysql database.
A brief introduction to mysql
When it comes to databases, we mostly think of relational databases, such as mysql, oracle, sqlserver and so on. These database software are very convenient to install on windows. If you want to install a database on Linux, we have to recommend mysql database first, and the first version of Mysql database is issued on the Linux system.
MySQL is a relational database management system developed by MySQL AB Company of Sweden and currently belongs to Oracle Company. MySQL is an associated database management system that stores data in different tables instead of 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. MySQL software adopts the double authorization policy (this entry "authorization policy"), which is divided into community version and commercial version. Because of its small size, high speed and low total cost of ownership, especially open source, the development of small and medium-sized websites generally choose MySQL as the website database. Because of the excellent performance of its community version, it can form a good development environment with PHP and Apache.
To install mysql database on Linux, we can download the rpm package of mysql database, http://dev.mysql.com/downloads/mysql/5.6.html#downloads, on its official website. You can download the corresponding database file according to your own operating system. The latest version is 5.6.10.
Here I install the mysql database through yum. By installing in this way, we can install some services and jar packages related to mysql, so it saves us a lot of unnecessary trouble!
2. Uninstall the original mysql
Because mysql database is so popular on Linux, the mainstream Linux system versions currently downloaded basically integrate mysql database in it. We can check whether mysql database has been installed on our operating system by using the following command
[root@xiaoluo ~] # rpm-qa | grep mysql / / this command will check whether the mysql database is installed on the operating system.
If so, we will uninstall it through the rpm-e command or the rpm-e-- nodeps command.
[root@xiaoluo ~] # rpm-e mysql / / normal delete mode [root@xiaoluo ~] # rpm-e-- nodeps mysql / / forcefully delete mode. If other dependent files are prompted when deleting using the above command, it can be forcefully deleted with this command.
After the deletion, we can use the rpm-qa | grep mysql command to see if mysql has been uninstalled successfully!
Third, install mysql through yum
I install the mysql database through yum. First, we can enter the yum list | grep mysql command to view the downloadable version of the mysql database available on yum:
[root@xiaoluo ~] # 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 typing the yum install-y mysql-server mysql mysql-devel command (Note: when we install mysql, we don't install the mysql client is equivalent to installing the mysql database, we also need to install the mysql-server server)
[root@xiaoluo ~] # yum install-y mysql-server mysql mysql-deve
After waiting for some time, yum will help us choose the software and other ancillary software needed to install the mysql database.
We found that installing the mysql database through yum saves a lot of unnecessary trouble. When the following result appears, it means that the mysql database installation is successful.
At this point, we can view the version of mysql-server that has just been installed with the following command
[root@xiaoluo ~] # rpm-qi mysql-server
The mysql-server we installed is not the latest version. If you want to try the latest version, just go to the mysql website to download the rpm package and install it. Our mysql database has been installed.
IV. Initialization and related configuration of mysql database
After we install the mysql database, we will find that there will be an extra mysqld service, which is our database service, and we can start our mysql service by typing the service mysqld start command.
Note: if this is the first time we start the mysql service, the mysql server will first initialize the configuration, such as:
[root@xiaoluo ~] # service mysqld start initializes MySQL database: WARNING: The host 'xiaoluo' could not be looked up with resolveip.This probably means that your libc libraries are not 100% compatiblewith this binary MySQL version. The MySQL daemon, mysqld, should worknormally with the exception that hostname resolving will not work.This means that you should use IP addresses instead of hostnameswhen specifying MySQL privileges! Installing MySQL system tables...OKFilling help tables...OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE 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_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly 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.plcd / usr/mysql-test; perl mysql-test-run.plPlease report any problems with the / usr/bin/mysqlbug script! [OK] starting mysqld: [OK]
At this time, we will see a lot of information after starting the mysql server for the first time, in order to initialize the mysql database. When we restart the mysql service again, we will not prompt so much information, such as:
[root@xiaoluo ~] # service mysqld restart stop mysqld: [OK] starting mysqld: [OK]
When we use the mysql database, we have to start the mysqld service first. We can check whether the mysql service starts automatically by using the command chkconfig-- list | grep mysqld, such as:
[root@xiaoluo ~] # chkconfig-- list | grep mysqldmysqld 0: close 1: close 2: close 3: close 4: close 5: close 6: close
We found that the mysqld service does not boot automatically. Of course, we can set it to boot by using the chkconfig mysqld on command, so that we don't have to start it manually every time.
[root@xiaoluo ~] # chkconfig mysqld on [root@xiaoluo ~] # chkconfig-- list | grep mysqlmysqld 0: off 1: off 2: enable 3: enable 4: enable 5: enable 6: close
After the mysql database is installed, there will only be one root administrator account, but the root account has not yet set a password for it. Some initialization of the database will be carried out when the mysql service is started for the first time. In the long list of information output, we can see the following line of information:
/ usr/bin/mysqladmin-u root password' new-password' / / set the password for the root account
So we can use this command to set a password for our root account (Note: this root account is a mysql root account, not a Linux root account)
[root@xiaoluo ~] # mysqladmin-u root password 'root' / / set the password to the root account as root through this command
At this point, we can log in to our mysql database with the mysql-u root-p command
5. The main configuration files of 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] # = / var/lib/=/var/lib/mysql/=--links=-error=/var/log/-=/var/run/mysqld/mysqld.pid
Database file storage location of 2./var/lib/mysql mysql database
The database files of our mysql database are usually stored in the / ver/lib/mysql directory
[root@xiaoluo] # cd / var/lib/mysql/ [root@xiaoluo mysql] # ls-l total dosage 20488 RWM RW Muhami. 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_logfile1drwx-. 2 mysql mysql 4096 April 6 21:59 mysql / / these are the default two database files srwxrwxrwx for mysql database installation. 1 mysql mysql 0 April 6 22:01 mysql.sockdrwx-. 2 mysql mysql 4096 April 6 21:59 test / / these are the default database files for mysql database installation
We can create a database ourselves to verify the location of the database file.
Create a database of our own: mysql > create database xiaoluo;Query OK, 1 row affected (0.00 sec) [root@xiaoluo mysql] # ls-l total usage 20492 RWQ. 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_logfile1drwx-. 2 mysql mysql 4096 April 6 21:59 mysqlsrwxrwxrwx. 1 mysql mysql 0 April 6 22:01 mysql.sockdrwx-. 2 mysql mysql 4096 April 6 21:59 testdrwx-. 2 mysql mysql 4096 April 6 22:15 xiaoluo/ / this is the xiaoluo database we just created by ourselves [root@xiaoluo mysql] # cd xiaoluo/ [root@xiaoluo xiaoluo] # lsdb.opt
Log output location of 3./var/log mysql database
Some of the log outputs of our mysql database are stored in the / var/log directory
[root@xiaoluo xiaoluo] # cd [root@xiaoluo ~] # cd / var/log [root@xiaoluo log] # lsamanda cron maillog-20130331 spice-vdagent.loganaconda.ifcfg.log cron-20130331 mcelog spooleranaconda.log cups messages spooler-20130331anaconda.program.log dirsrv messages-20130331 sssdanaconda.storage.log dmesg mysqld.log tallyloganaconda.syslog Dmesg.old ntpstats 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-20130401 libvirt samba Xorg.2.logcluster luci secure Xorg.9.logConsoleKit maillog secure-20130331 yum.log
The mysqld.log file is the log information we store when we operate with the mysql database. By looking at the log file, we can get a lot of information from it.
Because our mysql database can be accessed through the network, it is not a stand-alone database, and the protocol used in it is tcp/ip protocol. We all know that the port number of mysql database binding is 3306, so we can use the netstat-anp command to check whether the Linux system is listening on the port number 3306:
As shown above, the 3306 port number that the Linux system listens to is our mysql database!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.