search
HomeBackend DevelopmentPHP TutorialNginx and php installation and configuration nine mysql installation tutorial

The content of this article is about Nginx and PHP installation and configuration. It has a certain reference value. Friends in need can refer to it

1. Introduction to mysql

When it comes to databases, most of us 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, the first thing we have to recommend is the mysql database, and the first version of the Mysql database was 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. A relational database stores data in different tables instead of putting all data in one large warehouse, which increases speed and flexibility. MySQL's SQL language is the most commonly used standardized language for accessing databases. MySQL software adopts a dual authorization policy (this entry "Authorization Policy"), which is divided into community version and commercial version. Due to its small size, fast speed and low total cost of ownership, especially the characteristics of open source, it is generally used by small and medium-sized enterprises. For website development, MySQL is chosen as the website database. Due to the excellent performance of its community version, it can form a good development environment with PHP and Apache.

To 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 customize it according to your own needs operating system to download the corresponding database file. The latest version is 5.6.10.

Here I use yum to install the mysql database. By installing in this way, we can install some services and jar packages related to mysql, so we save a lot of trouble. Necessary trouble! ! !

2. Uninstall the original mysql

Because the mysql database is so popular on Linux, the mainstream Linux system currently downloaded The version basically integrates the mysql database in it. We can use the following command to check whether the mysql database has been installed on our operating system


##

[root@xiaoluo ~]# rpm -qa | grep mysql  // 这个命令就会查看该操作系统上是否已经安装了mysql数据库

If yes, we can uninstall it through rpm -e command or rpm -e --nodeps command

[root@xiaoluo ~]# rpm -e mysql  // 普通删除模式[root@xiaoluo ~]# rpm -e --nodeps mysql  // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除

Delete After that, we can use the rpm -qa | grep mysql command to check whether mysql has been successfully uninstalled! !

三、通过yum来进行mysql的安装

我是通过yum的方式来进行mysql的数据库安装,首先我们可以输入 yum list | grep mysql 命令来查看yum上提供的mysql数据库可下载的版本:

[root@xiaoluo ~]# yum list | grep mysql

就可以得到yum服务器上mysql数据库的可下载版本信息:

 

 

然后我们可以通过输入 yum install -y mysql-server mysql mysql-devel 命令将mysql mysql-server mysql-devel都安装好(注意:安装mysql时我们并不是安装了mysql客户端就相当于安装好了mysql数据库了,我们还需要安装mysql-server服务端才行)

 

[root@xiaoluo ~]# yum install -y mysql-server mysql mysql-deve

 

在等待了一番时间后,yum会帮我们选择好安装mysql数据库所需要的软件以及其它附属的一些软件

 

 

我们发现,通过yum方式安装mysql数据库省去了很多没必要的麻烦,当出现下面的结果时,就代表mysql数据库安装成功了

 

 

此时我们可以通过如下命令,查看刚安装好的mysql-server的版本

 

[root@xiaoluo ~]# rpm -qi mysql-server

 

我们安装的mysql-server并不是最新版本,如果你想尝试最新版本,那就去mysql官网下载rpm包安装就行了,至此我们的mysql数据库已经安装完成了。

四、mysql数据库的初始化及相关配置

我们在安装完mysql数据库以后,会发现会多出一个mysqld的服务,这个就是咱们的数据库服务,我们通过输入 service mysqld start 命令就可以启动我们的mysql服务。

注意:如果我们是第一次启动mysql服务,mysql服务器首先会进行初始化的配置,如:


Nginx and php installation and configuration nine mysql installation tutorial

[root@xiaoluo ~]# service mysqld start初始化 MySQL 数据库: 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_installationwhich 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!

                                                           [确定]
正在启动 mysqld:                                            [确定]

Nginx and php installation and configuration nine mysql installation tutorial

 

这时我们会看到第一次启动mysql服务器以后会提示非常多的信息,目的就是对mysql数据库进行初始化操作,当我们再次重新启动mysql服务时,就不会提示这么多信息了,如:

 

[root@xiaoluo ~]# service mysqld restart停止 mysqld:                                             [确定]
正在启动 mysqld:                                          [确定]

 

我们在使用mysql数据库时,都得首先启动mysqld服务,我们可以 通过  chkconfig --list | grep mysqld 命令来查看mysql服务是不是开机自动启动,如:

 

[root@xiaoluo ~]# chkconfig --list | grep mysqld
mysqld             0:关闭    1:关闭    2:关闭    3:关闭    4:关闭    5:关闭    6:关闭

 

我们发现mysqld服务并没有开机自动启动,我们当然可以通过 chkconfig mysqld on 命令来将其设置成开机启动,这样就不用每次都去手动启动了

 

[root@xiaoluo ~]# chkconfig mysqld on
[root@xiaoluo ~]# chkconfig --list | grep mysql
mysqld             0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭

 

mysql数据库安装完以后只会有一个root管理员账号,但是此时的root账号还并没有为其设置密码,在第一次启动mysql服务时,会进行数据库的一些初始化工作,在输出的一大串信息中,我们看到有这样一行信息 :

 

/usr/bin/mysqladmin -u root password 'new-password'  // 为root账号设置密码

 

所以我们可以通过 该命令来给我们的root账号设置密码(注意这个root账号是mysql的root账号,非Linux的root账号)

 

[root@xiaoluo ~]# mysqladmin -u root password 'root'  // 通过该命令给root账号设置密码为 root

 

此时我们就可以通过 mysql -u root -p 命令来登录我们的mysql数据库了

 

五、mysql数据库的主要配置文件

1./etc/my.cnf 这是mysql的主配置文件

我们可以查看一下这个文件的一些信息


Nginx and php installation and configuration nine mysql installation tutorial

[root@xiaoluo etc]# =/var/lib/=/var/lib/mysql/=--links=-error=/var/log/-=/var/run/mysqld/mysqld.pid

Nginx and php installation and configuration nine mysql installation tutorial

2./var/lib/mysql   mysql数据库的数据库文件存放位置

我们的mysql数据库的数据库文件通常是存放在了/ver/lib/mysql这个目录下

 


Nginx and php installation and configuration nine mysql installation tutorial

[root@xiaoluo ~]# cd /var/lib/mysql/[root@xiaoluo mysql]# ls -l
总用量 20488-rw-rw----. 1 mysql mysql 10485760 4月   6 22:01 ibdata1-rw-rw----. 1 mysql mysql  5242880 4月   6 22:01 ib_logfile0-rw-rw----. 1 mysql mysql  5242880 4月   6 21:59 ib_logfile1
drwx------. 2 mysql mysql     4096 4月   6 21:59 mysql  // 这两个是mysql数据库安装时默认的两个数据库文件srwxrwxrwx. 1 mysql mysql        0 4月   6 22:01 mysql.sock
drwx------. 2 mysql mysql     4096 4月   6 21:59 test  // 这两个是mysql数据库安装时默认的两个数据库文件

Nginx and php installation and configuration nine mysql installation tutorial

 

我们可以自己创建一个数据库,来验证一下该数据库文件的存放位置

 


Nginx and php installation and configuration nine mysql installation tutorial

创建一个我们自己的数据库:mysql> create database xiaoluo;
Query OK, 1 row affected (0.00 sec)

[root@xiaoluo mysql]# ls -l
总用量 20492-rw-rw----. 1 mysql mysql 10485760 4月   6 22:01 ibdata1-rw-rw----. 1 mysql mysql  5242880 4月   6 22:01 ib_logfile0-rw-rw----. 1 mysql mysql  5242880 4月   6 21:59 ib_logfile1
drwx------. 2 mysql mysql     4096 4月   6 21:59 mysql
srwxrwxrwx. 1 mysql mysql        0 4月   6 22:01 mysql.sock
drwx------. 2 mysql mysql     4096 4月   6 21:59 test
drwx------. 2 mysql mysql     4096 4月   6 22:15 xiaoluo  // 这个就是我们刚自己创建的xiaoluo数据库[root@xiaoluo mysql]# cd xiaoluo/[root@xiaoluo xiaoluo]# lsdb.opt

Nginx and php installation and configuration nine mysql installation tutorial

3./var/log mysql数据库的日志输出存放位置

我们的mysql数据库的一些日志输出存放位置都是在/var/log这个目录下


Nginx and php installation and configuration nine mysql installation tutorial

[root@xiaoluo xiaoluo]# cd 
[root@xiaoluo ~]# cd /var/log
[root@xiaoluo log]# lsamanda                cron           maillog-20130331   spice-vdagent.log
anaconda.ifcfg.log    cron-20130331  mcelog             spooler
anaconda.log          cups           messages           spooler-20130331anaconda.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

Nginx and php installation and configuration nine mysql installation tutorial

 

其中mysqld.log 这个文件就是我们存放我们跟mysql数据库进行操作而产生的一些日志信息,通过查看该日志文件,我们可以从中获得很多信息

 

因为我们的mysql数据库是可以通过网络访问的,并不是一个单机版数据库,其中使用的协议是 tcp/ip 协议,我们都知道mysql数据库绑定的端口号是 3306 ,所以我们可以通过 netstat -anp 命令来查看一下,Linux系统是否在监听 3306 这个端口号:

结果如上所示,Linux系统监听的3306端口号就是我们的mysql数据库!!!!

 

本篇随笔详细记录了在CentOS6.4下通过yum安装mysql数据库以及对数据库进行基本配置。

转自:http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html

相关推荐:

Nginx和php安装及配置八之nginx session的共享

Nginx和php安装及配置七之nginx负载均衡的5种策略

Nginx和php安装及配置六之Nginx反向代理和负载均衡部署指南

The above is the detailed content of Nginx and php installation and configuration nine mysql installation tutorial. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

How does PHP handle object cloning (clone keyword) and the __clone magic method?How does PHP handle object cloning (clone keyword) and the __clone magic method?Apr 17, 2025 am 12:24 AM

In PHP, use the clone keyword to create a copy of the object and customize the cloning behavior through the \_\_clone magic method. 1. Use the clone keyword to make a shallow copy, cloning the object's properties but not the object's properties. 2. The \_\_clone method can deeply copy nested objects to avoid shallow copying problems. 3. Pay attention to avoid circular references and performance problems in cloning, and optimize cloning operations to improve efficiency.

PHP vs. Python: Use Cases and ApplicationsPHP vs. Python: Use Cases and ApplicationsApr 17, 2025 am 12:23 AM

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools