Home Database Mysql Tutorial Linux数据库系统MySQL应用概述_MySQL

Linux数据库系统MySQL应用概述_MySQL

Jun 01, 2016 pm 02:11 PM
linux mysql Install application database Overview system


  我们建立数据库一个精髓就是要价廉而又要具有优良的性能。首先我们选择开放的Linux操作系统;同时可以在Linux下应用的数据库系统实在太多了,像Oracle的Oracle 8i、Sybase的 Sybase-ASE for Linux、PostgreSQL以及MySQL。本文要阐述的就是MySQL来基于Linux的数据库管理及应用。
  
  一、 MySQL概述。
  
  可以说这是中小企业网站Linux平台的首选自由数据库系统。它是一个跨平台数据库系统,一个真正
  的多用户、多线程的SQL数据库系统,同时是具有客户机/服务器体系结构的分布式数据库管理系统。同时,也是Linux系统中使用最为简单的数据库系统,安装简单、使用简单、管理也简单,且数据库系统的稳定性也很不错。
  
  二、 MySQL安装。
  
  其最新版本可以从http://www.mysql.com获得。跟所有Linux下服务器软件安装类似,一般其安装源
  有两类:RPM软件包和源码形式。根据你安装源不同,方法自然有区别,注意两类安装步骤都应以Root登入才行。
  
  1. RPM软件包。
  RPM软件包的最小安装:rpm -i MySQL-VERSION.i386.rpm MySQL-client-VERSION.i386.rpm
  如果只安装客户端:rpm -i MySQL-client-VERSION.i386.rpm
  通过以上安装,RPM即将数据放在了“/var/lib/mysql”文件里,同时也在“/etc/rc.d/”里创建适当的入口以便在引导时自动启动服务器。
  
  2. 源代码。
  先将其解压:tar -zxvf /tmp/mysql-3.22.21-pc-linux-gnu-i686.tar.gz
  ./ configure  ―――――――-检查相关配置并建立配置
  Make
  make install  ――――――――编译并安装
  
  三、 配置MySQL。
  
  安装完MySQL后, 它将会自动生成两个数据库。一个用于管理用户、主机和服务器数据库权限。另一个是测试数据库(test database)。
  
  1. 建立初始化的MySQL数据库(有些地方也称之为创建授权数据库表)。进入MySQL安装目录,输入以下命令,如果没有任何出错信息显示的话,表示就OK了:
  scripts/mysql_install_db
  exit
  
  2. 启动服务器:./ /mysql/bin/safe_mysqld &
  
  3. 创建mysql用户,例:useradd - c “ MySQL Administrator” - d /opt/mysql - g users mysql
  
  4. 安装树属权赋给mysql用户,例:chown - R msql.users /opt/msql
  
  四、 测试MySQL。
  
  经过以上几步,数据库应该可以正常使用了,我们可以对其作些基准测试。MySQL里面有一个简单的数据库例子test ,而且它的内部数据库一直保持对权限和帐户的监视,因而可以用此来先运行mysql看看是否可以工作。
  
  1. 如果安装的是RPM软件包,那么程序大都安装在/usr/local/mysql/bin。在此目录下运行客户端程序mysql后,如果出现诸如“Welcome to the MySQL monitor.。。。。“之类的信息,表示MySQL已成功启动。
  
  2. 用show databases命令可以列出安装的数据库清单。
  
  以上两步如都能看到相关信息,表示MySQL完全可以正常工作了。退出MySQL命令:EXIT。
  
  五、 常用命令实例
  
  1. 连接MYSQL
  比如我们要连接到远程主机上的MYSQL,并假定远程主机的IP地址为22.33.44.55,用户名为root,密码为1234567,命令格式为:mysql -h22.33.44.55 -uroot –p1234567
  而如果是连接到本机上的MYSQL,进入目录 mysqlbin后键入mysql -uroot -p,接着会提示你输密码,正确输入后即可进入MYSQL中了。
  
  2. 增加新用户
  增加一个用户user密码为1234567,让他只可以在localhost(本地主机,即MYSQL数据库所在的主机)上登录,并可以对数据库mydb进行查询、插入、修改、删除的操作:grant select,insert,update,delete on mydb.* to user@localhost identified by "1234567";
  
  3. 显示数据库列表:show databases
  初始MySQL就两个数据库:mysql和test。如上面“增加新用户”一步就是对mysql库的操作。
  
  4. 备份数据库
  进入mysqlbin目录后输入:mysqldump --opt system>backupsys.bbb(将数据库system备份到名为backup sys.bbb的文本文件)
  
  关于此类数据库操作命令还有很多,比如清空表记录delete from、显示数据表结构describe 表名;等等,大家可以参阅有关MySQL的详细教程。
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 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)

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

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.

Oracle's Role in the Business World Oracle's Role in the Business World Apr 23, 2025 am 12:01 AM

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

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.

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.

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.

laravel installation code laravel installation code Apr 18, 2025 pm 12:30 PM

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

How to safely store JavaScript objects containing functions and regular expressions to a database and restore? How to safely store JavaScript objects containing functions and regular expressions to a database and restore? Apr 19, 2025 pm 11:09 PM

Safely handle functions and regular expressions in JSON In front-end development, JavaScript is often required...

See all articles