iOS XMPP之mysql数据库的安装
一、安装 到MySQL官网上http://dev.mysql.com/downloads/mysql/,下载mysql可安装dmg版本 比如: Mac OS X ver. 10.7 (x86, 64-bit), DMG Archive 下载完的文件为:mysql-5.6.10-osx10.7-x86_64.dmg 1.点击,安装包里的 2.点击安装 安装好后,再系统偏好设置
一、安装
到MySQL官网上http://dev.mysql.com/downloads/mysql/,下载mysql可安装dmg版本
比如:Mac OS X ver. 10.7 (x86, 64-bit), DMG Archive
下载完的文件为:mysql-5.6.10-osx10.7-x86_64.dmg
1.点击,安装包里的
2.点击安装
安装好后,再系统偏好设置的其他里,会出现如下图标:
3.点击此图标,跳出对话框
点击Start MySQL Server按钮,启动mysql
二、打开终端,定义mysql别名
输入alias命令
alias mysql=/usr/local/mysql/bin/mysql
回车,再输入
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
三、设置mysql root帐号的密码
mysqladmin -u root password 初始密码
2.如果设置完密码后,需要修改,执行命令
mysqladmin -u root -p password 最新密码
接着会提示输入密码,此时输入旧密码,回车
四、连接数据库
mysql -u root -p
然后提示输入密码,输入三中设置的初始密码
2.如果登陆远程主机上的mysql数据库
mysql -h 主机地址 -u 用户名 -p 用户密码
五、执行常用的mysql数据库操作
注意:以下操作都发现在,连接数据库之后,进入mysql环境,之后执行的命令都必须带有分号“;”
首先,以root权限连接mysql
mysql -u root -p
然后,输入root的密码
1、增加新用户
格式如下:
grant 操作权限 on 数据库.* to 用户名@登陆主机地址 identified by <span>'</span><span>密码</span><span>';</span>
意思是:授予,某主机上的某用户(附带该用户的登陆密码)在某数据库上,执行某些操作的权限
(1)比如:任意主机上("%"),用户(用户名:test1,密码:adc)在所有数据库上,执行任意操作的权限(很危险)
grant all privileges on *.* to test1<span>@"</span><span>%</span><span>"</span> identified by <span>"</span><span>abc</span><span>"</span>;
其中all privileges表示查询,插入,修改,删除的权限:select,insert,update,delete
以上命令等价于:
grant <span>select</span>,insert,update,delete on *.* to test1<span>@"</span><span>%</span><span>"</span> identified by <span>"</span><span>abc</span><span>"</span>;
然后刷新权限
flush privileges;
(2)比如:授权本地主机上的用户操作数据库的权限
创建数据库(比如:openfire)
create database openfire;
授予本地主机用户(用户名:test2,密码:123)访问数据库(数据库名称:openfire)的操作权限
grant all privileges on openfire.* to test2@localhost identified by <span>"</span><span>123</span><span>"</span>;
flush privileges;
之后,就可以用新的用户,访问openfire数据库了
2.更新指定帐户的密码(用户名:test1,新密码:1234)
update mysql.user set password=password(<span>'</span><span>1234</span><span>'</span>) where User=<span>"</span><span>test1</span><span>"</span> and Host=<span>"</span><span>localhost</span><span>"</span>;
3.删除用户
先使用mysql数据库
use mysql;
删除mysql数据库中user表中的某个本地用户(test7)
delete from user where User=<span>"</span><span>test7</span><span>"</span> and Host=<span>"</span><span>localhost</span><span>"</span>;
4.显示命令
(1)显示所有数据库列表
show databases;
初始化只有两个数据库,mysql和test
注意:MYSQL的系统信息都存储在mysql库中,比如:修改密码和新增用户,实际上就是用这个库进行操作
(2)打开某个数据库(比如数据库:openfire)
use openfire;
(3)显示本库中的所有表
show tables;
(4)显示某表(table1)的结构
describe table1;
(5)建库
create database 库名;
(6)建表
<span>use 库名; create table 表名 (字段设定列表);</span>
(7)删库
drop database 库名;
(8)删表
drop table 表名;
(9)将表中的记录清空
delete from 表名;
(10)显示表中的记录
<span>select</span> * from 表名;
六、退出mysql
exit
七、启动和停止MySQL
启动
/usr/local/mysql/share/mysql.server start
停止
/usr/local/mysql/bin/mysqladmin -u root -p shutdown
输入root密码

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











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.

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.

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.

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 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.

Redis is a memory data structure storage system, mainly used as a database, cache and message broker. Its core features include single-threaded model, I/O multiplexing, persistence mechanism, replication and clustering functions. Redis is commonly used in practical applications for caching, session storage, and message queues. It can significantly improve its performance by selecting the right data structure, using pipelines and transactions, and monitoring and tuning.

MySQL and phpMyAdmin can be effectively managed through the following steps: 1. Create and delete database: Just click in phpMyAdmin to complete. 2. Manage tables: You can create tables, modify structures, and add indexes. 3. Data operation: Supports inserting, updating, deleting data and executing SQL queries. 4. Import and export data: Supports SQL, CSV, XML and other formats. 5. Optimization and monitoring: Use the OPTIMIZETABLE command to optimize tables and use query analyzers and monitoring tools to solve performance problems.

MySQL is suitable for rapid development and small and medium-sized applications, while Oracle is suitable for large enterprises and high availability needs. 1) MySQL is open source and easy to use, suitable for web applications and small and medium-sized enterprises. 2) Oracle is powerful and suitable for large enterprises and government agencies. 3) MySQL supports a variety of storage engines, and Oracle provides rich enterprise-level functions.
