I. mysql introduction speaking of databases, we mostly think of relational databases, such as mysql, oracle, and sqlserver. These database software is very convenient to install on windows, if you want to install a database on Linux, We have to first recommend the mysql database, and the first version of the Mysql database is released in the Linux system.
I. mysql introduction speaking of databases, we mostly think of relational databases, such as mysql, oracle, and sqlserver. These database software is very convenient to install on windows, if you want to install a database on Linux, We have to first recommend the mysql database, and the first version of the Mysql database is released in the Linux system.
I. mysql introduction speaking of databases, we mostly think of relational databases, such as mysql, oracle, and sqlserver. These database software is very convenient to install on windows, if you want to install a database on Linux, We have to first recommend the mysql database, and the first version of the Mysql database is released on Linux. MySQL is a relational database management system developed by MySQL AB in Sweden and currently belongs to Oracle. MySQL is an associated database management system that stores data in different tables rather than in a large warehouse. This increases the speed and flexibility. The SQL language of MySQL is the most commonly used standard language for accessing databases. MySQL adopts the dual Authorization Policy (this term "Authorization Policy"). It is divided into community edition and commercial edition. because of its small size, fast speed, and low total cost of ownership, especially open source code, MySQL is generally used as the website database for the development of small and medium-sized websites. Due to its superior performance, the Community edition works with PHP and Apache to form a good development environment. Install the mysql database on Linux. You can download the rpm package of the mysql database from its official website, http://dev.mysql.com/downloads/mysql/5.6.html#downloads You can download the corresponding database files based on your operating system. The latest version is 5.6.10. Here I use yum to install the mysql database. Through this method, we can install mysql-related services and jar packages, so it saves a lot of unnecessary trouble !!!? 2. Uninstall the original mysql. Because the mysql database is too popular on Linux, the mainstream Linux system versions downloaded are basically integrated with the mysql database, run the following command to check if mysql database is installed on our operating system [shell] [root@shitouer.cn ~] # Rpm-qa | grep mysql // command to check whether the mysql database [/shell] has been installed on the operating system, we can unmount the [shell] [root@shitouer.cn ~] through the rpm-e command or the rpm-e -- nodeps command. # Rpm-e mysql // normal deletion mode [root@shitouer.cn ~] # Rpm-e -- nodeps mysql // strong deletion mode. If the above command is used to delete a file, other dependent files are prompted, you can use this command to forcibly delete it. [/shell] after deletion, you can run the rpm-qa | grep mysql command to check whether mysql has been uninstalled successfully !! Iii. Install mysql through yum. I install mysql database through yum, first, we can enter the yum list | grep mysql command to view the mysql database on yum downloadable version: [root@shitouer.cn ~] # Yum list | grep mysql to obtain the downloadable version of the mysql database on the yum server. then, run the yum install-y mysql-server mysql-devel command to install mysql-server mysql-devel (note: when installing mysql, we do not install the mysql client is equivalent to installing the mysql database, we also need to install mysql-server) [shell] [root@shitouer.cn ~] # Yum install-y mysql-server mysql-deve [/shell] after waiting for some time, yum will help us select the software required to install the mysql database and some other ancillary software. We found that installing the mysql database through yum saves a lot of unnecessary trouble. When Complete occurs! The result indicates that the mysql database is successfully installed. At this time, we can use the following command to view the version of the newly installed mysql-server [shell] [root@shitouer.cn ~] # Rpm-qi mysql-server [/shell] 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. Now our mysql database has been installed .? 4. mysql database initialization and related configuration after we install the mysql database, we will find 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 initialize the configuration, such as: [shell] [root@shitouer.cn ~] # Service mysqld start initialize MySQL database: WARNING: The host 'shitouer. cn '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, shocould worknormally with the exception that host name resolving will not work. this means that you should use IP addresses instead of hostnameswhen specifying MySQL pri Vileges! 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 shitouer.cn 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 isstronugly recommended for production servers. see th E 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] mysqld is being started: [OK] [/shell] Then we will see a lot of information will be prompted after the mysql server is started for the first time, in order to initialize the mysql database, when we restart the mysql service again, so much information is not prompted, such as: [shell] [root@shitouer.cn ~] # Service mysqld restart stop mysqld: [OK] Starting mysqld: [OK] [/shell] When we use mysql database, we have to start mysqld service first, we can use the chkconfig -- list | grep mysqld command to check whether the mysql service is automatically started, such as: [shell] [root@shitouer.cn ~] # Chkconfig -- list | grep mysqldmysqld 0: Close 1: Close 2: Close 3: Close 4: Close 5: Close 6: to disable [/shell], we find that the mysqld service is not automatically started upon startup. Of course, we can use the chkconfig mysqld on command to set it to start upon startup, in this way, you don't have to manually start the [shell] [root@shitouer.cn ~] # Chkconfig mysqld on [root@shitouer.cn ~] # Chkconfig -- list | grep mysqlmysqld 0: Disable 1: Disable 2: Enable 3: Enable 4: Enable 5: Enable 6: close [/shell] After the mysql database is installed, there will only be one root administrator account, but the root account has not set a password for it. When the mysql service is started for the first time, database Initialization is performed. In a large string of output information, we can see this line of information: [shell]/usr/bin/mysqladmin-u root password 'new-password' // set the password for the root account [/shell], so we can use this command to give our root Account set the password for the Account (note: this root account is the root account of mysql, non-Linux root Account) [shell] [root@shitouer.cn ~] # Mysqladmin-u root password 'root' // Use this command to set the password of the root account to root [/shell]. Then we can log on to us using the mysql-u root-p command. mysql database [shell] [root@shitouer.cn ~] Mysql-u root-pmysql> show databases; [/shell] v. Main configuration file of mysql database 1. /etc/my. cnf this is the mysql main configuration file we can view some information of this file [shell] [root@shitouer.cn etc] # ls my. cnfmy. cnf [root@shitouer.cn etc] # cat my. cnf [mysqld] datadir =/var/lib/mysqlsocket =/var/lib/mysql. sockuser = mysql # Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links = 0 [mysqld_safe] log-error =/var/log/mysqld. logpid-file =/Var/run/mysqld. pid [/shell] 2. /var/lib/mysql database file storage location our mysql database file is usually stored in the/ver/lib/mysql directory [shell] [root@shitouer.cn ~] # Cd/var/lib/mysql/[root@shitouer.cn mysql] # ls-l total usage 20488-rw-rw ----. 1 mysql 10485760 April 6 22:01 ibdata1-rw-rw ----. 1 mysql 5242880 April 6 22:01 ib_logfile0-rw-rw ----. 1 mysql 5242880 April 6 21:59 ib_logfile1drwx ------. 2 mysql 4096 21:59 mysql // these two are the default two database files srwxrwxrwx during mysql database installation. 1 mysql 0 April 6 22:01 mysql. sockdrwx ------. 2 mysql 4096 April 6 21:59 test // Two are the default two database files for mysql database installation [/shell]. We can create a database by ourselves, to verify the storage location of the database file [shell] to create a database of our own: mysql> create database fowler; Query OK, 1 row affected (0.00 sec) [root@shitouer.cn mysql] # ls-l total usage 20316-rw-rw ----. 1 mysql 10485760 April 6 22:01 ibdata1-rw-rw ----. 1 mysql 5242880 April 6 22:01 ib_logfile0-rw-rw ----. 1 mysql 5242880 April 6 21:59 ib_logfile1drwx ------. 2 mysql 4096 21:59 mysqls Rwxrwxrwx. 1 mysql 0 April 6 22:01 mysql. sockdrwx ------. 2 mysql 4096 April 6 21:59 testdrwx ------. 2 mysql 4096 April 6 22:15 fowler // This is the fowler database we just created [root@shitouer.cn mysql] # cd fowler/[root@shitouer.cn fowler] # lsdb. opt [/shell] 3. /var/log mysql database log output storage location some of our mysql database log output storage location is in the/var/log directory [shell] [root@shitouer.cn fowler] # cd [root@shitouer.cn ~] # Cd/var/log [root@shitouer.cn 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 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. in log [/shell], mysqld. the log file is the log information generated when we operate with the mysql database. By viewing this log file, we can get a lot of information from this because our mysql database is accessible through the network, not a single-host database, where the protocol used is the TCP/IP protocol, we all know that the port number bound to the mysql database is 3306, so we can use the netstat-anp command to check whether the Linux system is listening for the port number 3306.