Home Database Mysql Tutorial Linux下用Perl进行MySQL数据库开发

Linux下用Perl进行MySQL数据库开发

Jun 07, 2016 pm 04:54 PM
mysql perl

Linux下用perl进行MySQL数据库开发需要安装MySQL,DBI和DBD。除了DBI比较好安装外,MySQL和DBD安装起来都没那么顺利,下面总结一

Linux下用perl进行MySQL数据库开发需要安装MySQL,DBI和DBD。除了DBI比较好安装外,MySQL和DBD安装起来都没那么顺利,下面总结一下安装错误解决方法:

一、MySQL数据库安装

1、下载MySQL的安装文件

安装MySQL需要下面两个文件:

MySQL-server-5.1.34.i386.rpm

MySQL-client-5.1.34.i386.rpm

下载地址为:http:,打开此网页,下拉网页找到“Linux x86 RPM downloads”项,,找到“Server”和“Client programs”项,下载需要的上述两个rpm文件。

2、安装MySQL

 rpm文件是Red Hat公司开发的软件安装包,rpm可让Linux在安装软件包时免除许多复杂的手续。该命令在安装时常用的参数是 –ivh ,其中i表示将安装指定的rmp软件包,V表示安装时的详细信息,h表示在安装期间出现“#”符号来显示目前的安装过程。这个符号将持续到安装完成后才停止。

1)安装服务器端

 在有两个rmp文件的目录下运行如下命令:

 [root@test1 local]# rpm -ivh MySQL-server-5.1.34.i386.rpm

 显示如下信息。

 warning: MySQL-server-5.1.34.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5

Preparing...   ########################################### [100%]

1:MySQL-server  ########################################### [100%]

 。。。。。。(省略显示)

 /usr/bin/mysqladmin -u root password \'new-password\'

 /usr/bin/mysqladmin -u root -h test1 password \'new-password\'

 。。。。。。(省略显示)

 Starting mysqld daemon with databases from /var/lib/mysql

如出现如上信息,服务端安装完毕。测试是否成功可运行netstat看Mysql端口是否打开,如打开表示服务已经启动,安装成功。Mysql默认的端口是3306。

[root@test1 local]# netstat -nat

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address    Foreign Address   State   

tcp  0  0 0.0.0.0:3306   0.0.0.0:*    LISTEN   

上面显示可以看出MySQL服务已经启动。

运行mysql命令测试mysql服务是否正常

错误一:

[root@localhost perl]# mysql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

解决方法:#ln –s /var/lib/mysql/mysql.sock /tmp/mysql.sock

错误二:

# mysql

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

解决方法:将/tmp下的mysql.sock删除

若果机器上有不同版本的mysql(未安装成功的),“rpm -ivh”时会提示版本冲突,应卸载以前的版本。

查看不同MySQL版本信息:

[root@localhost perl]# rpm -qa | grep -i mysql

MySQL-server-community-5.1.30-0.rhel5

MySQL-client-community-5.1.30-0.rhel5

卸载:

[root@localhost perl]# rpm -e MySQL-server-community

[root@localhost perl]# rpm -e MySQL-client-community

这样卸载后再执行“rpm -ivh”进行安装。

2)安装客户端

 运行如下命令:

 [root@test1 local]# rpm -ivh MySQL-client-5.1.34.i386.rpm

 warning: MySQL-client-5.1.34.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5

 Preparing... ########################################### [100%]

 1:MySQL-client########################################### [100%]

 显示安装完毕。

3)进入mysql

[root@localhost DBD-mysql-2.9003]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 59 to server version: 5.1.34-community

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| test               |

+--------------------+

3 rows in set (0.00 sec)

mysql>

linux

Statement of this Website
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

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1669
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
Laravel Introduction Example Laravel Introduction Example Apr 18, 2025 pm 12:45 PM

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

MySQL vs. Other Programming Languages: A Comparison MySQL vs. Other Programming Languages: A Comparison Apr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Laravel framework installation method Laravel framework installation method Apr 18, 2025 pm 12:54 PM

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

Explain the purpose of foreign keys in MySQL. Explain the purpose of foreign keys in MySQL. Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

Compare and contrast MySQL and MariaDB. Compare and contrast MySQL and MariaDB. Apr 26, 2025 am 12:08 AM

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

SQL vs. MySQL: Clarifying the Relationship Between the Two SQL vs. MySQL: Clarifying the Relationship Between the Two Apr 24, 2025 am 12:02 AM

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.

What software is better for yi framework? Recommended software for yi framework What software is better for yi framework? Recommended software for yi framework Apr 18, 2025 pm 11:03 PM

Abstract of the first paragraph of the article: When choosing software to develop Yi framework applications, multiple factors need to be considered. While native mobile application development tools such as XCode and Android Studio can provide strong control and flexibility, cross-platform frameworks such as React Native and Flutter are becoming increasingly popular with the benefits of being able to deploy to multiple platforms at once. For developers new to mobile development, low-code or no-code platforms such as AppSheet and Glide can quickly and easily build applications. Additionally, cloud service providers such as AWS Amplify and Firebase provide comprehensive tools

See all articles