Mysql数据库安装和配置

http://blog.csdn.net/pipisorry/article/details/46773507

Mysql数据库安装和配置、mysql语法、特殊符号及正則表達式的使用MySQL备份与恢复、Mysql存储引擎及选择方法、MySQL集群搭建

下载安装mysql

Windows下安装

Download MySQL Installer

安装时设置好管理账号和password就好了

Note:

1. 本地安装时假设没有安装好dependency可能不会安装 MySQL Workbench(sql集成开发环境).

2. MySQL Installer is 32 bit, but will install both 32 bit and 64 bit binaries.

3. 假设安装mysql时在start service那里停住了,安装不成功。请參考[django搭建站点记录一]

Linux下安装

下载Ubuntu / Debian (Architecture Independent), DEB[https://dev.mysql.com/downloads/repo/apt/]

(mysql-apt-config_0.8.2-1_all.deb) 14.5K
cd
mkdir mysql
cd mysql
wget https://repo.mysql.com//mysql-apt-config_0.8.2-1_all.deb 1> /dev/null
sudo dpkg -i mysql-apt-config_0.8.2-1_all.deb
#mysql 5.7
sudo apt-get update 1> /dev/null
sudo apt-get install mysql-server 1> /dev/null
#input passwd

[A Quick Guide to Using the MySQL APT Repository]

皮皮blog



启动mysql

Linux下启动mysqlserver

sudo service mysql status
#sudo service mysql stop    #stop
#sudo service mysql start    #start

建表

mysql -u root -p

#input passwd

create database vatic;

错误:mysql ERROR 1045 (28000): Access denied for user 'pika'@'localhost' (using password: NO) 解决:mysql -u root 改成 mysql -u root -p就会提示输入password了。

Windows下启动mysqlserver

1. windows任务栏mysql图标 > 右键 > running > start

2. start菜单 > all programs > Mysql > mysql notifier启动notifier就会在任务栏右边出现mysql图标并自己主动启动

启动mysql command line clientclient

start菜单 > all programs > Mysql > mysql server 5.6 > mysql command line client

在Django中启动mysql数据库服务环境

E:minepython_workspaceVoteSite>python manage.py dbshell

...

Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.6.24-log MySQL Community Server (GPL)

...
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql>

Note:假设出错python manage.py dbshell 'mysql' is not recognized as an internal or external command, operable prog,是由于mysql路径没有加入到系统路径中。加入了就能够了。

e.g.C:Program FilesMySQLMySQL Server 5.6inmysql.exe;

mysqld.exe 和 mysql.exe 有什么差别?

mysqld.exe 是MySQL后台程序(即MySQLserver)。要想使用client程序,该程序必须运行。由于client通过连接server来訪问数据库。


mysql.exe 是MySQL自带的命令行client工具,是交互式输入SQL语句或从文件以批处理模式运行它们的命令行工具。


简单来说:mysqld是用来启动mysql数据库的命令,mysql则是打开并运行sql语句的命令。

相关错误问题

mysql无法启动,无法改变状态

The Service MYSQL56 was not found in the Windows Service

Djangoserver无法启用

Can't connect to MySQL server on '127.0.0.1'([WinError] No connection could be made because the target machine actively refused it)

解决方式都是例如以下

任务栏右边mysql图标 > 右键 > action > manage monitored items > services > 删掉Mysql。打开instances页面,删掉instance > services > add > windows service > Mysql,就OK了!

皮皮blog



数据库文件

mysql数据库文件的存放路径

假设是LINUX上编译安装的话configure的时候指定--localstatedir=your_data_path;

假设是WINDOW上的:MySQL数据默认存储在"$MySQL的安装路径data"。

e.g. datadir="C:/ProgramData/MySQL/MySQL Server 5.5/Data/"  

Note:
1.找到MySQL的安装路径,用记事本打开 my.ini 这个文件。


2.在这个文件里找到例如以下内容:
#Path to the database root
datadir="C:/ProgramData/MySQL/MySQL Server 5.6/Data/"
假设你是要查看里面的内容,用数据库连接工具,或者命令行,通过 SLELECT 等语句就能够查询了。

MySQL创建数据库指定数据库的路径
方法1. 假设想让某个数据库db_name不存在这儿。能够在该数据库存放默认文件夹data以下建立一个文件为“db_name.sym”,当中内容是你想存储的地方的路径,比如“E:mysqldatadb_name”。确保这个文件夹存在。


方法2. 改动my.ini文件,把datadir="C:/ProgramData/MySQL/MySQL Server 5.1/Data/"改成你要的路径:D:Data,首先确保该路径存在,而且将C:/ProgramData/MySQL/MySQL Server 5.1/Data/以下的mysql文件夹复制到D:/Data/以下。假设不拷贝的话,mysql服务启动不了。重新启动mysql服务就可以

Note:

1. C:ProgramDataMySQLMySQL Server 5.6文件夹下有my.ini和my_2015-04-15T10-42-54.ini

2. C:Program FilesMySQLMySQL Server 5.6文件夹下有my-default.ini,须要管理员权限改动但也不要改动

移动数据库中的表文件

移动时会提示mysql正在使用。仅仅要关闭mysqlserver就能够了

皮皮blog


MySQL备份与恢复

[MySQL备份与恢复]


MySQL集群搭建

[怎样利用一个数据库中间件扩展MySQL集群——kingshard使用指南]


Mysql存储引擎及选择方法

[Mysql存储引擎及选择方法]

from:http://blog.csdn.net/pipisorry/article/details/46773507

ref:http://www.linuxidc.com/Linux/2013-07/88024.htm

[作者眼里的 MySQL 和 Oracle,还有 SQLite]


原文地址:https://www.cnblogs.com/yfceshi/p/6823412.html